Search in sources :

Example 16 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_readBlock_11.

@Test
public void trans_readBlock_11() {
    // JENA-91
    // READ(start)-WRITE-WRITE-WRITE-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgW2.commit();
    dsgW2.end();
    DatasetGraphTxn dsgW3 = sConn.begin(ReadWrite.WRITE);
    dsgW3.add(q3);
    dsgW3.commit();
    dsgW3.end();
    dsgR1.end();
    sConn.flush();
    DatasetGraphTDB dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    assertTrue(dsg.contains(q2));
    assertTrue(dsg.contains(q3));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 17 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_readBlock_08.

@Test
public void trans_readBlock_08() {
    // WRITE(start)-add-READ(start)-WRITE(commit)-READ sees old DSG.
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    assertFalse(dsgR1.contains(q));
    dsgW.commit();
    dsgW.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    // Before view
    assertFalse(dsgR1.contains(q));
    // After view
    assertTrue(dsgR2.contains(q));
    dsgR1.end();
    dsgR2.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 18 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_05.

@Test
public void trans_05() {
    // WRITE(commit)-WRITE(commit)-READ-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgW2.commit();
    dsgW2.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgR2.contains(q1));
    assertTrue(dsgR2.contains(q2));
    dsgR2.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    assertTrue(dsg.contains(q2));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 19 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_readBlock_02.

@Test
public void trans_readBlock_02() {
    // READ(start)-WRITE(abort)-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    dsgW.abort();
    dsgW.end();
    assertFalse(dsgR1.contains(q));
    dsgR1.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertFalse(dsgR2.contains(q));
    dsgR2.end();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertFalse(dsg.contains(q));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 20 with DatasetGraphTxn

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

the class T_TransSystem method beforeClass.

@BeforeClass
public static void beforeClass() {
    if (!LOC.isMem())
        FileOps.clearDirectory(LOC.getDirectoryPath());
    StoreConnection.reset();
    StoreConnection sConn = StoreConnection.make(LOC);
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.WRITE);
    dsg.add(q1);
    dsg.add(q2);
    initCount = 2;
    dsg.commit();
    dsg.end();
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) BeforeClass(org.junit.BeforeClass)

Aggregations

DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)33 StoreConnection (org.apache.jena.tdb.StoreConnection)32 BaseTest (org.apache.jena.atlas.junit.BaseTest)27 Test (org.junit.Test)27 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)15 ConfigTest (org.apache.jena.tdb.ConfigTest)8 Dataset (org.apache.jena.query.Dataset)2 Quad (org.apache.jena.sparql.core.Quad)2 Location (org.apache.jena.tdb.base.file.Location)2 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Model (org.apache.jena.rdf.model.Model)1 BeforeClass (org.junit.BeforeClass)1