Search in sources :

Example 1 with PutResult

use of org.apache.bookkeeper.api.kv.result.PutResult in project bookkeeper by apache.

the class TestMVCCAsyncBytesStoreImpl method testPutGetDeleteRanges.

@Test
public void testPutGetDeleteRanges() throws Exception {
    this.streamName = "test-put-kvs";
    StateStoreSpec spec = initSpec(streamName);
    result(store.init(spec));
    int numPairs = 100;
    List<PutResult<byte[], byte[]>> kvs = writeKVs(numPairs, true);
    assertEquals(numPairs, kvs.size());
    for (PutResult<byte[], byte[]> kv : kvs) {
        assertEquals(Code.OK, kv.code());
        assertNull(kv.prevKv());
        kv.close();
    }
    verifyRange(20, 70, 2, 2, 0);
    List<KeyValue<byte[], byte[]>> prevKvs = result(store.deleteRange(getKey(20), getKey(70)));
    assertNotNull(prevKvs);
    verifyRecords(prevKvs, 20, 70, 2, 2, 0);
    prevKvs.forEach(KeyValue::close);
    prevKvs = result(store.range(getKey(20), getKey(70)));
    assertTrue(prevKvs.isEmpty());
}
Also used : KeyValue(org.apache.bookkeeper.api.kv.result.KeyValue) StateStoreSpec(org.apache.bookkeeper.statelib.api.StateStoreSpec) PutResult(org.apache.bookkeeper.api.kv.result.PutResult) Test(org.junit.Test)

Aggregations

KeyValue (org.apache.bookkeeper.api.kv.result.KeyValue)1 PutResult (org.apache.bookkeeper.api.kv.result.PutResult)1 StateStoreSpec (org.apache.bookkeeper.statelib.api.StateStoreSpec)1 Test (org.junit.Test)1