use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class tdbstats method stats.
public static StatsResults stats(DatasetGraphTDB dsg, Node gn) {
NodeTable nt = dsg.getTripleTable().getNodeTupleTable().getNodeTable();
StatsCollectorNodeId stats = new StatsCollectorNodeId(nt);
if (gn == null) {
Iterator<Tuple<NodeId>> iter = dsg.getTripleTable().getNodeTupleTable().findAll();
for (; iter.hasNext(); ) {
Tuple<NodeId> t = iter.next();
stats.record(null, t.get(0), t.get(1), t.get(2));
}
} else {
// If the union graph, then we need to scan all quads but with uniqueness.
boolean unionGraph = Quad.isUnionGraph(gn);
NodeId gnid = null;
if (!unionGraph) {
gnid = nt.getNodeIdForNode(gn);
if (NodeId.isDoesNotExist(gnid))
Log.warn(tdbstats.class, "No such graph: " + gn);
}
NodeTupleTable ntt = dsg.getQuadTable().getNodeTupleTable();
Iterator<Tuple<NodeId>> iter = unionGraph ? SolverLib.unionGraph(ntt) : ntt.find(gnid, null, null, null);
for (; iter.hasNext(); ) {
Tuple<NodeId> t = iter.next();
stats.record(t.get(0), t.get(1), t.get(2), t.get(3));
}
}
return stats.results();
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class tdbnode method exec.
@Override
protected void exec() {
DatasetGraphTDB dsg = getDatasetGraphTDB();
NodeTable nodeTable = dsg.getTripleTable().getNodeTupleTable().getNodeTable();
Iterator<String> iter = super.getPositional().iterator();
if (!iter.hasNext()) {
System.err.println("No node ids");
return;
}
for (; iter.hasNext(); ) {
String id = iter.next();
try {
long x = Long.parseLong(id);
NodeId nodeId = new NodeId(x);
Node n = nodeTable.getNodeForNodeId(nodeId);
//System.out.printf("%s [%d] => %s\n", id, x, n) ;
Hash h = new Hash(SystemTDB.LenNodeHash);
NodeLib.setHash(h, n);
String str = Bytes.asHex(h.getBytes());
System.out.printf("%s %08d 0x%s # %s\n", id, x, str, n);
} catch (Exception ex) {
System.out.println("Failed to decode: " + id);
}
}
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class TestNodeId method nodeId_02.
@Test
public void nodeId_02() {
NodeId nodeId = NodeId.create(-1L);
assertEquals(-1L, nodeId.getId());
}
use of org.apache.jena.tdb.store.NodeId 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 ds) {
DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
final NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
final NodeId target = nodeTable.getNodeIdForNode(NodeFactory.createURI(graphToHide));
return item -> !(item.len() == 4 && item.get(0).equals(target));
}
use of org.apache.jena.tdb.store.NodeId in project jena by apache.
the class AbstractTestNodeTable method writeNode.
protected static void writeNode(NodeTable nt, Node n) {
NodeId nodeId = nt.getAllocateNodeId(n);
assertNotNull(nodeId);
assertNotEquals(NodeId.NodeDoesNotExist, nodeId);
assertNotEquals(NodeId.NodeIdAny, nodeId);
Node n2 = nt.getNodeForNodeId(nodeId);
assertEquals(n, n2);
NodeId nodeId2 = nt.getNodeIdForNode(n);
assertEquals(nodeId, nodeId2);
}
Aggregations