Search in sources :

Example 1 with RangeRequest

use of org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest in project bookkeeper by apache.

the class TestKvUtils method testNewRangeRequest.

@Test
public void testNewRangeRequest() {
    try (RangeOption<ByteBuf> rangeOption = optionFactory.newRangeOption().endKey(key.retainedDuplicate()).countOnly(true).keysOnly(true).limit(10).maxCreateRev(1234L).minCreateRev(234L).maxModRev(2345L).minModRev(1235L).build()) {
        RangeRequest rr = newRangeRequest(key, rangeOption).build();
        assertEquals(keyBs, rr.getKey());
        assertEquals(keyBs, rr.getRangeEnd());
        assertTrue(rr.getCountOnly());
        assertTrue(rr.getKeysOnly());
        assertEquals(10, rr.getLimit());
        assertEquals(1234L, rr.getMaxCreateRevision());
        assertEquals(234L, rr.getMinCreateRevision());
        assertEquals(2345L, rr.getMaxModRevision());
        assertEquals(1235L, rr.getMinModRevision());
        assertFalse(rr.hasHeader());
    }
}
Also used : KvUtils.newKvRangeRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvRangeRequest) RangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest) DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) KvUtils.newRangeRequest(org.apache.bookkeeper.clients.impl.kv.KvUtils.newRangeRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with RangeRequest

use of org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest in project bookkeeper by apache.

the class StorageContainerImpl method range.

// 
// Table API
// 
@Override
public CompletableFuture<StorageContainerResponse> range(StorageContainerRequest request) {
    checkArgument(KV_RANGE_REQ == request.getRequestCase());
    long scId = request.getScId();
    RangeRequest rr = request.getKvRangeReq();
    RoutingHeader header = rr.getHeader();
    RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
    TableStore store = tableStoreCache.getTableStore(rid);
    if (null != store) {
        return store.range(request);
    } else {
        return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.range(request));
    }
}
Also used : RangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest) DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) RoutingHeader(org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader) RangeId(org.apache.bookkeeper.stream.protocol.RangeId) TableStore(org.apache.bookkeeper.stream.storage.api.kv.TableStore)

Aggregations

DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 RangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.RangeRequest)2 ByteBuf (io.netty.buffer.ByteBuf)1 KvUtils.newKvRangeRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newKvRangeRequest)1 KvUtils.newRangeRequest (org.apache.bookkeeper.clients.impl.kv.KvUtils.newRangeRequest)1 RoutingHeader (org.apache.bookkeeper.stream.proto.kv.rpc.RoutingHeader)1 RangeId (org.apache.bookkeeper.stream.protocol.RangeId)1 TableStore (org.apache.bookkeeper.stream.storage.api.kv.TableStore)1 Test (org.junit.Test)1