use of org.apache.jena.tdb.store.nodetable.NodeTable 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 = TupleLib.convertToQuads(nodeTable, iterMatches) ;
Iterator<Quad> qIter = Iter.map(iterMatches, asQuad);
return qIter;
}
use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class DumpOps method dump.
public static void dump(Dataset ds) {
DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
NodeTupleTable nodeTupleTableTriples = dsg.getTripleTable().getNodeTupleTable();
NodeTupleTable nodeTupleTableQuads = dsg.getQuadTable().getNodeTupleTable();
if (nodeTupleTableTriples.getNodeTable() != nodeTupleTableQuads.getNodeTable())
throw new TDBException("Different node tables for triples and quads");
NodeTable nodeTable = nodeTupleTableTriples.getNodeTable();
// V special.
Set<NodeTable> dumpedNodeTables = new HashSet<>();
if (true) {
System.out.print("## Node Table\n");
dumpNodeTable(nodeTupleTableTriples.getNodeTable(), dumpedNodeTables);
dumpNodeTable(nodeTupleTableQuads.getNodeTable(), dumpedNodeTables);
}
if (false) {
System.out.print("## Triple Table\n");
dumpNodeTupleTable(nodeTupleTableTriples.getTupleTable());
System.out.print("## Quad Table\n");
dumpNodeTupleTable(nodeTupleTableQuads.getTupleTable());
}
// Indexes.
if (true) {
dumpTupleIndexes(nodeTupleTableTriples.getTupleTable().getIndexes());
dumpTupleIndexes(nodeTupleTableQuads.getTupleTable().getIndexes());
}
// Prefixes
if (true) {
System.out.print("## Prefix Table\n");
DatasetPrefixesTDB prefixes = dsg.getStoragePrefixes();
NodeTupleTable pntt = prefixes.getNodeTupleTable();
if (!dumpedNodeTables.contains(pntt.getNodeTable())) {
dumpNodeTable(pntt.getNodeTable(), dumpedNodeTables);
dumpedNodeTables.add(pntt.getNodeTable());
}
dumpTupleIndexes(prefixes.getNodeTupleTable().getTupleTable().getIndexes());
}
}
Aggregations