Search in sources :

Example 6 with NodeTableTrans

use of org.apache.jena.tdb.transaction.NodeTableTrans in project jena by apache.

the class AbstractTestNodeTableTrans method nodetrans_03.

@Test
public void nodetrans_03() {
    Transaction txn = createTxn(11);
    NodeTableTrans ntt = create(txn);
    NodeTable nt0 = ntt.getBaseNodeTable();
    ntt.begin(txn);
    // Add a node
    NodeId nodeId = ntt.getAllocateNodeId(node1);
    // Check not in the base.
    assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node1));
    assertNull(nt0.getNodeForNodeId(nodeId));
    // Check is in the transaction node table.
    assertEquals(node1, ntt.getNodeForNodeId(nodeId));
    ntt.abort(txn);
    // Check it is not in the base.
    assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node1));
    assertNull(nt0.getNodeForNodeId(nodeId));
    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 7 with NodeTableTrans

use of org.apache.jena.tdb.transaction.NodeTableTrans 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 8 with NodeTableTrans

use of org.apache.jena.tdb.transaction.NodeTableTrans in project jena by apache.

the class AbstractTestNodeTableTrans method create.

private NodeTableTrans create(Transaction txn, NodeTable base) {
    RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
    Index idx = new IndexMap(recordFactory);
    ObjectFile objectFile = createObjectFile();
    NodeTableTrans ntt = new NodeTableTrans(txn, "test", base, idx, objectFile);
    return ntt;
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) IndexMap(org.apache.jena.tdb.index.IndexMap) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) Index(org.apache.jena.tdb.index.Index)

Aggregations

NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)8 BaseTest (org.apache.jena.atlas.junit.BaseTest)7 Transaction (org.apache.jena.tdb.transaction.Transaction)7 Test (org.junit.Test)7 NodeId (org.apache.jena.tdb.store.NodeId)5 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)3 ObjectFile (org.apache.jena.tdb.base.objectfile.ObjectFile)1 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)1 Index (org.apache.jena.tdb.index.Index)1 IndexMap (org.apache.jena.tdb.index.IndexMap)1