Search in sources :

Example 71 with NodeId

use of org.apache.jena.tdb.store.NodeId 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);
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) Transaction(org.apache.jena.tdb.transaction.Transaction) NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 72 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class TDBInternal method getNodeId.

/**
     * Return the NodeId for a node. Returns NodeId.NodeDoesNotExist when the
     * node is not found. Returns null when not a TDB-backed dataset.
     */
public static NodeId getNodeId(DatasetGraphTDB dsg, Node node) {
    if (dsg == null)
        return null;
    NodeTable nodeTable = dsg.getQuadTable().getNodeTupleTable().getNodeTable();
    NodeId nodeId = nodeTable.getNodeIdForNode(node);
    return nodeId;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 73 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class NodeTableTrans method getAllocateNodeId.

@Override
public NodeId getAllocateNodeId(Node node) {
    if (passthrough)
        return base.getAllocateNodeId(node);
    NodeId nodeId = getNodeIdForNode(node);
    if (!NodeId.isDoesNotExist(nodeId))
        return nodeId;
    // add to journal
    nodeId = allocate(node);
    return nodeId;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId)

Example 74 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class NodeTableTrans method getNodeIdForNode.

@Override
public NodeId getNodeIdForNode(Node node) {
    if (node == Node.ANY)
        return NodeId.NodeIdAny;
    if (passthrough)
        return base.getNodeIdForNode(node);
    NodeId nodeId = nodeTableJournal.getNodeIdForNode(node);
    if (!NodeId.isDoesNotExist(nodeId))
        return mapFromJournal(nodeId);
    nodeId = base.getNodeIdForNode(node);
    return nodeId;
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId)

Example 75 with NodeId

use of org.apache.jena.tdb.store.NodeId in project jena by apache.

the class NodeTableTrans method dump.

// Debugging only
private void dump() {
    System.err.println(">>>>>>>>>>");
    System.err.println("label = " + label);
    System.err.println("txn = " + txn);
    System.err.println("offset = " + allocOffset);
    System.err.println("journalStartOffset = " + journalObjFileStartOffset);
    System.err.println("journal = " + journalObjFile.getLabel());
    if (true)
        return;
    System.err.println("nodeTableJournal >>>");
    Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all();
    for (; iter.hasNext(); ) {
        Pair<NodeId, Node> x = iter.next();
        NodeId nodeId = x.getLeft();
        Node node = x.getRight();
        NodeId mapped = mapFromJournal(nodeId);
        //debug("append: %s -> %s", x, mapFromJournal(nodeId)) ;
        // This does the write.
        NodeId nodeId2 = base.getAllocateNodeId(node);
        System.err.println(x + "  mapped=" + mapped + " getAlloc=" + nodeId2);
    }
    System.err.println("journal >>>");
    Iterator<Pair<Long, ByteBuffer>> iter1 = this.journalObjFile.all();
    for (; iter1.hasNext(); ) {
        Pair<Long, ByteBuffer> p = iter1.next();
        System.err.println(p.getLeft() + " : " + p.getRight());
        ByteBufferLib.print(System.err, p.getRight());
    }
    System.err.println("nodeIndex >>>");
    Iterator<Record> iter2 = this.nodeIndex.iterator();
    for (; iter2.hasNext(); ) {
        Record r = iter2.next();
        System.err.println(r);
    }
    System.err.println("<<<<<<<<<<");
}
Also used : Node(org.apache.jena.graph.Node) NodeId(org.apache.jena.tdb.store.NodeId) Record(org.apache.jena.tdb.base.record.Record) ByteBuffer(java.nio.ByteBuffer) Pair(org.apache.jena.atlas.lib.Pair)

Aggregations

NodeId (org.apache.jena.tdb.store.NodeId)76 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)29 BaseTest (org.apache.jena.atlas.junit.BaseTest)28 Test (org.junit.Test)28 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)20 Node (org.apache.jena.graph.Node)18 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)10 Pair (org.apache.jena.atlas.lib.Pair)5 Var (org.apache.jena.sparql.core.Var)5 TDBException (org.apache.jena.tdb.TDBException)5 Record (org.apache.jena.tdb.base.record.Record)5 StatsCollectorNodeId (org.apache.jena.tdb.solver.stats.StatsCollectorNodeId)5 NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)5 Transaction (org.apache.jena.tdb.transaction.Transaction)5 Predicate (java.util.function.Predicate)2 Location (org.apache.jena.tdb.base.file.Location)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 StatsResults (org.apache.jena.tdb.solver.stats.StatsResults)2 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)2 Hash (org.apache.jena.tdb.store.Hash)2