Search in sources :

Example 1 with GetResponse

use of org.tikv.kvproto.Kvrpcpb.GetResponse in project client-java by tikv.

the class RegionStoreClient method get.

/**
 * Fetch a value according to a key
 *
 * @param backOffer backOffer
 * @param key key to fetch
 * @param version key version
 * @return value
 * @throws TiClientInternalException TiSpark Client exception, unexpected
 * @throws KeyException Key may be locked
 */
public ByteString get(BackOffer backOffer, ByteString key, long version) throws TiClientInternalException, KeyException {
    boolean forWrite = false;
    Supplier<GetRequest> factory = () -> GetRequest.newBuilder().setContext(makeContext(getResolvedLocks(version), this.storeType, backOffer.getSlowLog())).setKey(key).setVersion(version).build();
    KVErrorHandler<GetResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
    GetResponse resp = callWithRetry(backOffer, TikvGrpc.getKvGetMethod(), factory, handler);
    handleGetResponse(resp);
    return resp.getValue();
}
Also used : RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) GetRequest(org.tikv.kvproto.Kvrpcpb.GetRequest) RawGetRequest(org.tikv.kvproto.Kvrpcpb.RawGetRequest) BatchGetRequest(org.tikv.kvproto.Kvrpcpb.BatchGetRequest) KVErrorHandler(org.tikv.common.operation.KVErrorHandler) BatchGetResponse(org.tikv.kvproto.Kvrpcpb.BatchGetResponse) GetResponse(org.tikv.kvproto.Kvrpcpb.GetResponse) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) RawGetResponse(org.tikv.kvproto.Kvrpcpb.RawGetResponse)

Example 2 with GetResponse

use of org.tikv.kvproto.Kvrpcpb.GetResponse in project tispark by pingcap.

the class RegionStoreClient method get.

/**
 * Fetch a value according to a key
 *
 * @param backOffer backOffer
 * @param key key to fetch
 * @param version key version
 * @return value
 * @throws TiClientInternalException TiSpark Client exception, unexpected
 * @throws KeyException Key may be locked
 */
public ByteString get(BackOffer backOffer, ByteString key, long version) throws TiClientInternalException, KeyException {
    boolean forWrite = false;
    Supplier<GetRequest> factory = () -> GetRequest.newBuilder().setContext(region.getContext(getResolvedLocks(version))).setKey(key).setVersion(version).build();
    KVErrorHandler<GetResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> resp.hasError() ? resp.getError() : null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
    GetResponse resp = callWithRetry(backOffer, TikvGrpc.getKvGetMethod(), factory, handler);
    handleGetResponse(resp);
    return resp.getValue();
}
Also used : RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) GetRequest(org.tikv.kvproto.Kvrpcpb.GetRequest) RawGetRequest(org.tikv.kvproto.Kvrpcpb.RawGetRequest) BatchGetRequest(org.tikv.kvproto.Kvrpcpb.BatchGetRequest) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) BatchGetResponse(org.tikv.kvproto.Kvrpcpb.BatchGetResponse) GetResponse(org.tikv.kvproto.Kvrpcpb.GetResponse) RawGetResponse(org.tikv.kvproto.Kvrpcpb.RawGetResponse)

Aggregations

BatchGetRequest (org.tikv.kvproto.Kvrpcpb.BatchGetRequest)2 BatchGetResponse (org.tikv.kvproto.Kvrpcpb.BatchGetResponse)2 GetRequest (org.tikv.kvproto.Kvrpcpb.GetRequest)2 GetResponse (org.tikv.kvproto.Kvrpcpb.GetResponse)2 RawBatchGetRequest (org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest)2 RawBatchGetResponse (org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse)2 RawGetRequest (org.tikv.kvproto.Kvrpcpb.RawGetRequest)2 RawGetResponse (org.tikv.kvproto.Kvrpcpb.RawGetResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 KVErrorHandler (org.tikv.common.operation.KVErrorHandler)1