use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class NodeTableTrans method append.
/** Copy from the journal file to the real file */
/*package*/
void append() {
Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all();
Pair<NodeId, Node> firstPair = null;
Pair<NodeId, Node> lastPair = null;
for (; iter.hasNext(); ) {
Pair<NodeId, Node> x = iter.next();
if (firstPair == null)
firstPair = x;
lastPair = x;
NodeId nodeId = x.getLeft();
Node node = x.getRight();
debug(" append: %s -> %s", x, mapFromJournal(nodeId));
// This does the write.
NodeId nodeId2 = base.getAllocateNodeId(node);
if (!nodeId2.equals(mapFromJournal(nodeId)))
inconsistent(node, nodeId, nodeId2);
}
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class SolverLib method graphNames.
/** Find all the graph names in the quads table. */
public static QueryIterator graphNames(DatasetGraphTDB ds, Node graphNode, QueryIterator input, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
List<Abortable> killList = new ArrayList<>();
Iterator<Tuple<NodeId>> iter1 = ds.getQuadTable().getNodeTupleTable().find(NodeId.NodeIdAny, NodeId.NodeIdAny, NodeId.NodeIdAny, NodeId.NodeIdAny);
if (filter != null)
iter1 = Iter.filter(iter1, filter);
Iterator<NodeId> iter2 = Iter.map(iter1, (t) -> t.get(0));
iter2 = makeAbortable(iter2, killList);
Iterator<NodeId> iter3 = Iter.distinct(iter2);
iter3 = makeAbortable(iter3, killList);
Iterator<Node> iter4 = NodeLib.nodes(ds.getQuadTable().getNodeTupleTable().getNodeTable(), iter3);
final Var var = Var.alloc(graphNode);
Iterator<Binding> iterBinding = Iter.map(iter4, node -> BindingFactory.binding(var, node));
// Not abortable.
return new QueryIterTDB(iterBinding, killList, input, execCxt);
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class SolverLib method testForGraphName.
/** Find whether a specific graph name is in the quads table. */
public static QueryIterator testForGraphName(DatasetGraphTDB ds, Node graphNode, QueryIterator input, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
NodeId nid = TDBInternal.getNodeId(ds, graphNode);
boolean exists = !NodeId.isDoesNotExist(nid);
if (exists) {
// Node exists but is it used in the quad position?
NodeTupleTable ntt = ds.getQuadTable().getNodeTupleTable();
// Don't worry about abortable - this iterator should be fast
// (with normal indexing - at least one G???).
// Either it finds a starting point, or it doesn't. We are only
// interested in the first .hasNext.
Iterator<Tuple<NodeId>> iter1 = ntt.find(nid, NodeId.NodeIdAny, NodeId.NodeIdAny, NodeId.NodeIdAny);
if (filter != null)
iter1 = Iter.filter(iter1, filter);
exists = iter1.hasNext();
}
if (exists)
return input;
else {
input.close();
return QueryIterNullIterator.create(execCxt);
}
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class SolverLib method convertToNodeIds.
public static Set<NodeId> convertToNodeIds(Collection<Node> nodes, DatasetGraphTDB dataset) {
Set<NodeId> graphIds = new HashSet<>();
NodeTable nt = dataset.getQuadTable().getNodeTupleTable().getNodeTable();
for (Node n : nodes) graphIds.add(nt.getNodeIdForNode(n));
return graphIds;
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class LoaderNodeTupleTable method copyIndex.
static void copyIndex(Iterator<Tuple<NodeId>> srcIter, TupleIndex[] destIndexes, String label, LoadMonitor monitor) {
monitor.startIndex(label);
long counter = 0;
for (; srcIter.hasNext(); ) {
counter++;
Tuple<NodeId> tuple = srcIter.next();
monitor.indexItem();
for (TupleIndex destIdx : destIndexes) {
if (destIdx != null)
destIdx.add(tuple);
}
}
monitor.finishIndex(label);
}
Aggregations