Search in sources :

Example 26 with NodeId

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

the class AbstractTestTupleIndex method TupleIndexRecordFindNot_5.

@Test
public void TupleIndexRecordFindNot_5() {
    TupleIndex index = createIndex("SPO");
    add(index, n1, n2, n3);
    add(index, n1, n5, n6);
    Tuple<NodeId> tuple2 = TupleFactory.tuple(n2, n5, n6);
    Iterator<Tuple<NodeId>> iter = index.find(tuple2);
    assertFalse(iter.hasNext());
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 27 with NodeId

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

the class AbstractTestTupleIndex method TupleIndexRecordFindNot_3.

@Test
public void TupleIndexRecordFindNot_3() {
    TupleIndex index = createIndex("SPO");
    add(index, n1, n2, n3);
    Tuple<NodeId> tuple2 = TupleFactory.tuple(n1, null, n6);
    Iterator<Tuple<NodeId>> iter = index.find(tuple2);
    assertFalse(iter.hasNext());
}
Also used : NodeId(org.apache.jena.tdb.store.NodeId) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 28 with NodeId

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

the class AbstractTestNodeTableTrans method nodetrans_06.

@Test
public void nodetrans_06() {
    // 2 transactions - blocking reader - create a second NodeTableTrans
    Transaction txn1 = createTxn(11);
    NodeTableTrans ntt1 = create(txn1, node1);
    NodeId nodeId1 = ntt1.getBaseNodeTable().getNodeIdForNode(node1);
    ntt1.begin(txn1);
    NodeId nodeId2 = ntt1.getAllocateNodeId(node2);
    ntt1.commitPrepare(txn1);
    // READ - don't enact
    Transaction txn2 = createTxn(12);
    NodeTableTrans ntt2 = create(txn2, ntt1.getBaseNodeTable());
    ntt2.begin(txn2);
    assertEquals(nodeId1, ntt2.getNodeIdForNode(node1));
    assertEquals(nodeId2, ntt2.getNodeIdForNode(node2));
    NodeId nodeId3 = ntt2.getAllocateNodeId(node3);
    assertEquals(nodeId3, ntt2.getNodeIdForNode(node3));
    ntt2.commitPrepare(txn2);
    // READ ends.
    ntt1.commitEnact(txn1);
    ntt1.commitClearup(txn1);
    ntt2.commitEnact(txn2);
    ntt2.commitClearup(txn2);
    assertEquals(nodeId1, ntt1.getBaseNodeTable().getNodeIdForNode(node1));
    assertEquals(nodeId2, ntt1.getBaseNodeTable().getNodeIdForNode(node2));
    assertEquals(nodeId3, ntt1.getBaseNodeTable().getNodeIdForNode(node3));
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) Transaction(org.apache.jena.tdb.transaction.Transaction) NodeId(org.apache.jena.tdb.store.NodeId) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 29 with NodeId

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

the class AbstractTestNodeTableTrans method nodetrans_05.

@Test
public void nodetrans_05() {
    // 2 transactions - no blocking reader - create a second NodeTableTrans
    Transaction txn1 = createTxn(11);
    NodeTableTrans ntt1 = create(txn1, node1);
    NodeId nodeId1 = ntt1.getBaseNodeTable().getNodeIdForNode(node1);
    ntt1.begin(txn1);
    NodeId nodeId2 = ntt1.getAllocateNodeId(node2);
    ntt1.commitPrepare(txn1);
    ntt1.commitEnact(txn1);
    ntt1.commitClearup(txn1);
    Transaction txn2 = createTxn(12);
    NodeTableTrans ntt2 = create(txn2, ntt1.getBaseNodeTable());
    ntt2.begin(txn2);
    assertEquals(nodeId1, ntt2.getNodeIdForNode(node1));
    assertEquals(nodeId2, ntt2.getNodeIdForNode(node2));
    NodeId nodeId3 = ntt2.getAllocateNodeId(node3);
    assertEquals(nodeId3, ntt2.getNodeIdForNode(node3));
    ntt2.commitPrepare(txn2);
    ntt2.commitEnact(txn2);
    ntt2.commitClearup(txn2);
    assertEquals(nodeId1, ntt1.getBaseNodeTable().getNodeIdForNode(node1));
    assertEquals(nodeId2, ntt1.getBaseNodeTable().getNodeIdForNode(node2));
    assertEquals(nodeId3, ntt1.getBaseNodeTable().getNodeIdForNode(node3));
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) Transaction(org.apache.jena.tdb.transaction.Transaction) NodeId(org.apache.jena.tdb.store.NodeId) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 30 with NodeId

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

the class AbstractTestNodeTableTrans method nodetrans_02.

@Test
public void nodetrans_02() {
    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.
    assertNull(nt0.getNodeForNodeId(nodeId));
    // Check is in the transaction node table.
    assertEquals(NodeId.NodeDoesNotExist, nt0.getNodeIdForNode(node1));
    assertEquals(node1, ntt.getNodeForNodeId(nodeId));
    ntt.commitPrepare(txn);
    ntt.commitEnact(txn);
    // Check it is now in the base.
    assertEquals(node1, nt0.getNodeForNodeId(nodeId));
    assertEquals(nodeId, nt0.getNodeIdForNode(node1));
    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)

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