use of org.apache.jena.tdb2.store.NodeId in project jena by apache.
the class BindingTDB method get1.
@Override
public Node get1(Var var) {
try {
Node n = cacheGet(var);
if (n != null)
return n;
NodeId id = idBinding.get(var);
if (id == null)
return null;
if (NodeId.isDoesNotExist(id))
return null;
n = nodeTable.getNodeForNodeId(id);
if (n == null)
// But there was to put it in the BindingNodeId.
throw new TDBException("No node in NodeTable for NodeId " + id);
// Update cache.
cachePut(var, n);
return n;
} catch (Exception ex) {
Log.error(this, String.format("get1(%s)", var), ex);
return null;
}
}
use of org.apache.jena.tdb2.store.NodeId in project jena by apache.
the class BindingTDB method fmtVar.
@Override
protected void fmtVar(StringBuffer sbuff, Var var) {
NodeId id = idBinding.get(var);
String extra = "";
if (id != null)
extra = "/" + id;
Node node = get(var);
String tmp = NodeFmtLib.displayStr(node);
sbuff.append("( ?" + var.getVarName() + extra + " = " + tmp + " )");
}
use of org.apache.jena.tdb2.store.NodeId 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.NodeId in project jena by apache.
the class StageMatchTuple method tupleToBinding.
private static BindingNodeId tupleToBinding(BindingNodeId input, Tuple<NodeId> tuple, Var[] var) {
// Reuseable BindingNodeId builder?
BindingNodeId output = new BindingNodeId(input);
for (int i = 0; i < var.length; i++) {
Var v = var[i];
if (v == null)
continue;
NodeId id = tuple.get(i);
if (!compatible(output, v, id))
return null;
output.put(v, id);
}
return output;
}
use of org.apache.jena.tdb2.store.NodeId 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;
}
Aggregations