use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class TupleIndex method scan.
public static Iterator<Tuple<NodeId>> scan(Iterator<Tuple<NodeId>> iter, Tuple<NodeId> pattern) {
int tupleLength = pattern.len();
Predicate<Tuple<NodeId>> filter = new Predicate<Tuple<NodeId>>() {
@Override
public boolean test(Tuple<NodeId> item) {
// Check on pattern and item (both in natural order)
for (int i = 0; i < tupleLength; i++) {
NodeId n = pattern.get(i);
// The pattern must be null/Any or match the tuple being tested.
if (!NodeId.isAny(n))
if (!item.get(i).equals(n))
return false;
}
return true;
}
};
return Iter.filter(iter, filter);
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class TupleTable method find.
/** Find all matching tuples - a slot of NodeId.NodeIdAny (or null) means match any */
public Iterator<Tuple<NodeId>> find(Tuple<NodeId> pattern) {
if (tupleLen != pattern.len())
throw new TDBException(format("Mismatch: finding tuple of length %d in a table of tuples of length %d", pattern.len(), tupleLen));
int numSlots = 0;
// Canonical form.
for (int i = 0; i < tupleLen; i++) {
NodeId x = pattern.get(i);
if (!NodeId.isAny(x))
numSlots++;
}
if (numSlots == 0)
return scanAllIndex.all();
int indexNumSlots = 0;
TupleIndex index = null;
for (TupleIndex idx : indexes) {
if (idx != null) {
int w = idx.weight(pattern);
if (w > indexNumSlots) {
indexNumSlots = w;
index = idx;
}
}
}
if (index == null)
// No index at all. Scan.
index = indexes[0];
return index.find(pattern);
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class NodeTableTrans method allocate.
private NodeId allocate(Node node) {
NodeId nodeId = nodeTableJournal.getAllocateNodeId(node);
nodeId = mapFromJournal(nodeId);
return nodeId;
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class DebugTDB method lookup.
public static NodeId lookup(DatasetGraphTDB dsg, Node n) {
NodeTable nt = dsg.getTripleTable().getNodeTupleTable().getNodeTable();
NodeId nid = nt.getNodeIdForNode(n);
return nid;
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class NodeTableTrans method allocOffset.
@Override
public NodeId allocOffset() {
if (passthrough)
return base.allocOffset();
// If we have done the append stage, this is invalid as the base may change under our feet
// Would need to track base operations.
NodeId x1 = nodeTableJournal.allocOffset();
NodeId x2 = mapFromJournal(x1);
return x2;
}
Aggregations