use of org.apache.jena.tdb.store.nodetable.NodeTable 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.nodetable.NodeTable 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 ? SolverLibTDB.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.nodetable.NodeTable in project jena by apache.
the class AbstractTestNodeTable method testNodeBad.
protected void testNodeBad(Node badNode) {
NodeTable nt = createEmptyNodeTable();
writeBadNode(nt, badNode);
}
use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class AbstractTestNodeTableTrans method nodetrans_04.
@Test
public void nodetrans_04() {
Transaction txn = createTxn(11);
NodeTableTrans ntt = create(txn, node1);
NodeTable nt0 = ntt.getBaseNodeTable();
ntt.begin(txn);
// Add a node
NodeId nodeId = ntt.getAllocateNodeId(node2);
// Not here
assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node2));
// Is here
assertEquals(nodeId, ntt.getNodeIdForNode(node2));
ntt.commitPrepare(txn);
ntt.commitEnact(txn);
assertEquals(nodeId, nt0.getNodeIdForNode(node2));
ntt.commitClearup(txn);
}
use of org.apache.jena.tdb.store.nodetable.NodeTable in project jena by apache.
the class JournalControl method recoverNodeDat.
/** Recover a node data file (".dat").
* Node data files are append-only so recovering, then not using the data is safe.
* Node data file is a precursor for full recovery that works from the master journal.
*/
private static void recoverNodeDat(DatasetGraphTDB dsg, FileRef fileRef) {
// See DatasetBuilderTxn - same name generation code.
RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
NodeTable baseNodeTable = dsg.getConfig().nodeTables.get(fileRef);
String objFilename = fileRef.getFilename() + "-" + Names.extJournal;
objFilename = dsg.getLocation().absolute(objFilename);
File jrnlFile = new File(objFilename);
if (jrnlFile.exists() && jrnlFile.length() > 0) {
syslog.info("Recovering node data: " + fileRef.getFilename());
ObjectFile dataJrnl = FileFactory.createObjectFileDisk(objFilename);
NodeTableTrans ntt = new NodeTableTrans(null, objFilename, baseNodeTable, new IndexMap(recordFactory), dataJrnl);
ntt.append();
ntt.close();
dataJrnl.close();
baseNodeTable.sync();
}
if (jrnlFile.exists())
FileOps.delete(objFilename);
}
Aggregations