Search in sources :

Example 1 with StateMgrDataIdx

use of org.apache.jena.dboe.transaction.txn.StateMgrDataIdx in project jena by apache.

the class TestStateMgrData method state_data_02.

@Test
public void state_data_02() {
    BufferChannel x = FileFactory.createBufferChannelMem();
    long[] data = { 2, 3 };
    StateMgrDataIdx sm = new StateMgrDataIdx(x, data);
    sm.writeState();
    sm.set(1, 99L);
    sm.writeState();
    ByteBuffer bb = ByteBuffer.allocate(2 * Long.BYTES);
    x.read(bb, 0);
    assertEquals(99L, bb.getLong(Long.BYTES));
}
Also used : BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) StateMgrDataIdx(org.apache.jena.dboe.transaction.txn.StateMgrDataIdx) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 2 with StateMgrDataIdx

use of org.apache.jena.dboe.transaction.txn.StateMgrDataIdx in project jena by apache.

the class TestStateMgrData method state_data_03.

@Test
public void state_data_03() {
    BufferChannel x = FileFactory.createBufferChannelMem();
    {
        ByteBuffer bb = ByteBuffer.allocate(Long.BYTES);
        bb.putLong(0, -8888);
        bb.rewind();
        x.write(bb);
        bb.putLong(0, -1234);
        bb.rewind();
        x.write(bb);
        x.sync();
    }
    long[] data = { 2, 3 };
    StateMgrDataIdx sm = new StateMgrDataIdx(x, data);
    assertEquals(-8888L, sm.get(0));
    assertEquals(-1234L, sm.get(1));
}
Also used : BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) StateMgrDataIdx(org.apache.jena.dboe.transaction.txn.StateMgrDataIdx) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 3 with StateMgrDataIdx

use of org.apache.jena.dboe.transaction.txn.StateMgrDataIdx in project jena by apache.

the class TestStateMgrData method state_data_01.

@Test
public void state_data_01() {
    BufferChannel x = FileFactory.createBufferChannelMem();
    long[] data = { 2, 3 };
    StateMgrDataIdx sm = new StateMgrDataIdx(x, data);
    assertEquals(data.length, sm.getData().length);
    assertEquals(2L, sm.get(0));
    assertEquals(3L, sm.get(1));
    // Test initial state written
    ByteBuffer bb = ByteBuffer.allocate(2 * Long.BYTES);
    x.read(bb, 0);
    assertEquals(2L, bb.getLong(0));
    assertEquals(3L, bb.getLong(Long.BYTES));
}
Also used : BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) StateMgrDataIdx(org.apache.jena.dboe.transaction.txn.StateMgrDataIdx) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)3 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)3 StateMgrDataIdx (org.apache.jena.dboe.transaction.txn.StateMgrDataIdx)3 Test (org.junit.Test)3