use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class DatasetBuilderStd method makeNodeTable.
public NodeTable makeNodeTable(Location location, StoreParams params) {
FileSet fsNodeToId = new FileSet(location, params.getIndexNode2Id());
FileSet fsId2Node = new FileSet(location, params.getIndexId2Node());
NodeTable nt = nodeTableBuilder.buildNodeTable(fsNodeToId, fsId2Node, params);
return nt;
}
use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class SolverLib method execute.
// The worker. Callers choose the NodeTupleTable.
// graphNode may be Node.ANY, meaning we should make triples unique.
// graphNode may be null, meaning default graph
private static QueryIterator execute(NodeTupleTable nodeTupleTable, Node graphNode, BasicPattern pattern, QueryIterator input, Predicate<Tuple<NodeId>> filter, ExecutionContext execCxt) {
if (Quad.isUnionGraph(graphNode))
graphNode = Node.ANY;
if (Quad.isDefaultGraph(graphNode))
graphNode = null;
List<Triple> triples = pattern.getList();
boolean anyGraph = (graphNode == null ? false : (Node.ANY.equals(graphNode)));
int tupleLen = nodeTupleTable.getTupleTable().getTupleLen();
if (graphNode == null) {
if (3 != tupleLen)
throw new TDBException("SolverLib: Null graph node but tuples are of length " + tupleLen);
} else {
if (4 != tupleLen)
throw new TDBException("SolverLib: Graph node specified but tuples are of length " + tupleLen);
}
// Convert from a QueryIterator (Bindings of Var/Node) to BindingNodeId
NodeTable nodeTable = nodeTupleTable.getNodeTable();
Iterator<BindingNodeId> chain = Iter.map(input, SolverLib.convFromBinding(nodeTable));
List<Abortable> killList = new ArrayList<>();
for (Triple triple : triples) {
Tuple<Node> tuple = null;
if (graphNode == null)
// 3-tuples
tuple = tuple(triple.getSubject(), triple.getPredicate(), triple.getObject());
else
// 4-tuples.
tuple = tuple(graphNode, triple.getSubject(), triple.getPredicate(), triple.getObject());
chain = solve(nodeTupleTable, tuple, anyGraph, chain, filter, execCxt);
chain = makeAbortable(chain, killList);
}
// DEBUG POINT
if (false) {
if (chain.hasNext())
chain = Iter.debug(chain);
else
System.out.println("No results");
}
// Timeout wrapper ****
// QueryIterTDB gets called async.
// Iter.abortable?
// Or each iterator has a place to test.
// or pass in a thing to test?
// Need to make sure the bindings here point to parent.
Iterator<Binding> iterBinding = convertToNodes(chain, nodeTable);
// "killList" will be aborted on timeout.
return new QueryIterTDB(iterBinding, killList, input, execCxt);
}
use of org.apache.jena.tdb.store.nodetable.NodeTable 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.nodetable.NodeTable in project jena by apache.
the class dumpnodetable method exec.
@Override
protected void exec() {
List<String> tripleIndexes = Arrays.asList(Names.tripleIndexes);
List<String> quadIndexes = Arrays.asList(Names.quadIndexes);
Location loc = modLocation.getLocation();
StoreConnection sConn = StoreConnection.make(loc);
DatasetGraphTDB dsg = sConn.getBaseDataset();
NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
dump(System.out, nodeTable);
}
use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class AbstractTestNodeTable method testNode.
protected void testNode(Node n) {
NodeTable nt = createEmptyNodeTable();
writeNode(nt, n);
}
Aggregations