use of org.apache.jena.tdb2.store.nodetable.NodeTable in project jena by apache.
the class NodeTableOps method bulkNodeToNodeIdImpl.
/**
* Convert a bulk operation into a loop
*/
public static List<NodeId> bulkNodeToNodeIdImpl(NodeTable nt, List<Node> nodes, boolean withAllocation) {
List<NodeId> nodeIds = new ArrayList<>(nodes.size());
for (Node node : nodes) {
NodeId nid = withAllocation ? nt.getAllocateNodeId(node) : nt.getNodeIdForNode(node);
nodeIds.add(nid);
}
return nodeIds;
}
use of org.apache.jena.tdb2.store.nodetable.NodeTable in project jena by apache.
the class TestQuadFilter method createFilter.
/**
* Create a filter to exclude the graph http://example/g2
*/
private static Predicate<Tuple<NodeId>> createFilter(Dataset dataset) {
return Txn.calculateRead(dataset, () -> {
DatasetGraphTDB dsg = TDBInternal.getDatasetGraphTDB(dataset);
final NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
final NodeId target = nodeTable.getNodeIdForNode(NodeFactory.createURI(graphToHide));
// Check g slot. Exclude graphToHide
return item -> !(item.len() == 4 && item.get(0).equals(target));
});
}
use of org.apache.jena.tdb2.store.nodetable.NodeTable in project jena by apache.
the class NodeTableLib method printNodeTable.
/**
* Print the main node table - development helper
*/
public static void printNodeTable(DatasetGraph dsg, long limit) {
dsg.executeRead(() -> {
DatasetGraphTDB dsgtdb = TDBInternal.getDatasetGraphTDB(dsg);
NodeTable nodeTable = dsgtdb.getTripleTable().getNodeTupleTable().getNodeTable();
int x = 0;
for (var iter = nodeTable.all(); iter.hasNext(); ) {
var pair = iter.next();
x++;
if (x > limit)
return;
NodeId nid = pair.getLeft();
Node n = pair.getRight();
System.out.printf("%s %s\n", nid, NodeFmtLib.strNT(n));
}
// long x = Iter.count(nodeTable.all());
System.out.println("Node table length: " + x);
});
}
Aggregations