Search in sources :

Example 86 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestTransControl method queueBatchSize_03.

@Test
public void queueBatchSize_03() {
    TransactionManager.QueueBatchSize = 2;
    DatasetGraph dsg = create();
    TransactionManager tMgr = TDBInternal.getTransactionManager(dsg);
    txnAddData(dsg);
    assertEquals(1, tMgr.getQueueLength());
    txnAddData(dsg);
    assertEquals(2, tMgr.getQueueLength());
    txnAddData(dsg);
    assertEquals(0, tMgr.getQueueLength());
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 87 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestTransControl method journalThresholdSize_03.

// Intermediate flush journal size.
@Test
public void journalThresholdSize_03() {
    TransactionManager.QueueBatchSize = 100;
    TransactionManager.MaxQueueThreshold = -1;
    // More than commit size, less than block.
    TransactionManager.JournalThresholdSize = 1000;
    DatasetGraph dsg = create();
    TransactionManager tMgr = TDBInternal.getTransactionManager(dsg);
    // About 20 bytes.
    Txn.executeWrite(dsg, () -> {
    });
    assertEquals(1, tMgr.getQueueLength());
    txnAddData(dsg);
    assertEquals(0, tMgr.getQueueLength());
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 88 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_01.

@Test
public void trans_readBlock_01() {
    // READ(start)-WRITE(commit)-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    dsgW.commit();
    dsgW.end();
    assertFalse(dsgR1.contains(q));
    dsgR1.end();
    //**** Not hitting the queue ****
    // Order of tweaking counters?
    // also writer and counters?
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgR2.contains(q));
    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 89 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_03.

@Test
public void trans_readBlock_03() {
    // READ(start)-WRITE(commit)-WRITE(commit)-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();
    assertFalse(dsgR1.contains(q1));
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgW2.commit();
    dsgW2.end();
    assertFalse(dsgR1.contains(q1));
    assertFalse(dsgR1.contains(q2));
    dsgR1.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 90 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_09.

@Test
public void trans_readBlock_09() {
    // WRITE(commit)-READ(start)-WRITE(commit)-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    dsgW2.commit();
    dsgW2.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgR1.contains(q1));
    assertFalse(dsgR1.contains(q2));
    assertTrue(dsgR2.contains(q1));
    assertTrue(dsgR2.contains(q2));
    dsgR1.end();
    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)

Aggregations

DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)222 Test (org.junit.Test)132 BaseTest (org.apache.jena.atlas.junit.BaseTest)59 Quad (org.apache.jena.sparql.core.Quad)47 Node (org.apache.jena.graph.Node)29 Graph (org.apache.jena.graph.Graph)18 StoreConnection (org.apache.jena.tdb.StoreConnection)17 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)15 Model (org.apache.jena.rdf.model.Model)10 IOException (java.io.IOException)7 Triple (org.apache.jena.graph.Triple)7 Dataset (org.apache.jena.query.Dataset)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 ResultSet (org.apache.jena.query.ResultSet)5 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)5 Element (org.apache.jena.sparql.syntax.Element)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 RiotException (org.apache.jena.riot.RiotException)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4