use of org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable in project jena by apache.
the class SolverLibTDB method testForGraphName.
/**
* Find whether a specific graph name is in the quads table.
*/
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.tdb2.store.nodetupletable.NodeTupleTable in project jena by apache.
the class TDB2StorageBuilder method buildPrefixTable.
private StoragePrefixesTDB buildPrefixTable(NodeTable prefixNodes) {
String primary = params.getPrimaryIndexPrefix();
String[] indexes = params.getPrefixIndexes();
TupleIndex[] prefixIndexes = makeTupleIndexes(primary, indexes);
if (prefixIndexes.length != 1)
error(log, "Wrong number of triple table tuples indexes: " + prefixIndexes.length);
// No cache - the prefix mapping is a cache
// NodeTable prefixNodes = makeNodeTable(location, pnNode2Id, pnId2Node, -1, -1, -1);
NodeTupleTable prefixTable = new NodeTupleTableConcrete(primary.length(), prefixIndexes, prefixNodes);
StoragePrefixesTDB x = new StoragePrefixesTDB(txnSystem, prefixTable);
// DatasetPrefixesTDB prefixes = new DatasetPrefixesTDB(prefixTable);
log.debug("Prefixes: " + primary + " :: " + String.join(",", indexes));
return x;
}
use of org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable in project jena by apache.
the class SolverRX method accessData.
static Iterator<Quad> accessData(Tuple<Node> patternTuple, NodeTupleTable nodeTupleTable, boolean anyGraph, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
NodeTable nodeTable = nodeTupleTable.getNodeTable();
Function<Tuple<NodeId>, Quad> asQuad = asQuad(nodeTable, nodeTupleTable.getTupleLen(), anyGraph);
Tuple<NodeId> patternTupleId = TupleLib.tupleNodeIds(nodeTable, patternTuple);
if (patternTupleId.contains(NodeId.NodeDoesNotExist))
// Can not match.
return Iter.nullIterator();
// -- DRY/StageMatchTuple ??
Iterator<Tuple<NodeId>> iterMatches = nodeTupleTable.find(patternTupleId);
// Add filter
if (filter != null)
iterMatches = Iter.filter(iterMatches, filter);
// Add anyGraph
if (anyGraph) {
// See StageMatchTuple for discussion.
iterMatches = Iter.map(iterMatches, quadsToAnyTriples);
iterMatches = Iter.distinctAdjacent(iterMatches);
}
// -- DRY/StageMatchTuple
Iterator<Quad> qIter = Iter.map(iterMatches, asQuad);
return qIter;
}
use of org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable in project jena by apache.
the class DatasetGraphTDB method listGraphNodes.
@Override
public Iterator<Node> listGraphNodes() {
checkNotClosed();
NodeTupleTable quads = getQuadTable().getNodeTupleTable();
Iterator<Tuple<NodeId>> x = quads.findAll();
// XXX Future: Ensure we scan a G??? index and use distinctAdjacent.
// See TupleTable.chooseScanAllIndex
Iterator<NodeId> z = Iter.iter(x).map(t -> t.get(0)).distinct();
Iterator<Node> r = NodeLib.nodes(quads.getNodeTable(), z);
return r;
}
use of org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable in project jena by apache.
the class DataToTuplesInline method startBulk.
@Override
public void startBulk() {
coordinator = CoLib.newCoordinator();
CoLib.add(coordinator, nodeTable);
// Prefixes
NodeTupleTable p = prefixes.getNodeTupleTable();
CoLib.add(coordinator, p.getNodeTable());
CoLib.add(coordinator, p.getTupleTable().getIndexes());
CoLib.start(coordinator);
transaction = coordinator.begin(TxnType.WRITE);
}
Aggregations