Search in sources :

Example 1 with DeleteRangeRequest

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

the class StorageContainerImpl method delete.

@Override
public CompletableFuture<StorageContainerResponse> delete(StorageContainerRequest request) {
    checkArgument(KV_DELETE_REQ == request.getRequestCase());
    long scId = request.getScId();
    DeleteRangeRequest rr = request.getKvDeleteReq();
    RoutingHeader header = rr.getHeader();
    RangeId rid = RangeId.of(header.getStreamId(), header.getRangeId());
    TableStore store = tableStoreCache.getTableStore(rid);
    if (null != store) {
        return store.delete(request);
    } else {
        return tableStoreCache.openTableStore(scId, rid).thenCompose(s -> s.delete(request));
    }
}
Also used : 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)

Example 2 with DeleteRangeRequest

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

the class TestKvUtils method testNewDeleteRequest.

@Test
public void testNewDeleteRequest() {
    try (DeleteOption<ByteBuf> option = optionFactory.newDeleteOption().endKey(key.retainedDuplicate()).prevKv(true).build()) {
        DeleteRangeRequest rr = newDeleteRequest(key, option).build();
        assertEquals(keyBs, rr.getKey());
        assertEquals(keyBs, rr.getRangeEnd());
        assertTrue(rr.getPrevKv());
        assertFalse(rr.hasHeader());
    }
}
Also used : DeleteRangeRequest(org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

DeleteRangeRequest (org.apache.bookkeeper.stream.proto.kv.rpc.DeleteRangeRequest)2 ByteBuf (io.netty.buffer.ByteBuf)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