Search in sources :

Example 1 with RawBatchGetRequest

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

the class RegionStoreClient method rawBatchGet.

public List<KvPair> rawBatchGet(BackOffer backoffer, List<ByteString> keys) {
    Long clusterId = pdClient.getClusterId();
    Histogram.Timer requestTimer = GRPC_RAW_REQUEST_LATENCY.labels("client_grpc_raw_batch_get", clusterId.toString()).startTimer();
    try {
        if (keys.isEmpty()) {
            return new ArrayList<>();
        }
        Supplier<RawBatchGetRequest> factory = () -> RawBatchGetRequest.newBuilder().setContext(makeContext(storeType, backoffer.getSlowLog())).addAllKeys(keys).build();
        RegionErrorHandler<RawBatchGetResponse> handler = new RegionErrorHandler<RawBatchGetResponse>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
        RawBatchGetResponse resp = callWithRetry(backoffer, TikvGrpc.getRawBatchGetMethod(), factory, handler);
        return handleRawBatchGet(resp);
    } finally {
        requestTimer.observeDuration();
    }
}
Also used : Histogram(io.prometheus.client.Histogram) RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) ArrayList(java.util.ArrayList) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) RegionErrorHandler(org.tikv.common.operation.RegionErrorHandler)

Example 2 with RawBatchGetRequest

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

the class RegionStoreClient method rawBatchGet.

public List<KvPair> rawBatchGet(BackOffer backoffer, List<ByteString> keys) {
    if (keys.isEmpty()) {
        return new ArrayList<>();
    }
    Supplier<RawBatchGetRequest> factory = () -> RawBatchGetRequest.newBuilder().setContext(region.getContext()).addAllKeys(keys).build();
    KVErrorHandler<RawBatchGetResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
    RawBatchGetResponse resp = callWithRetry(backoffer, TikvGrpc.getRawBatchGetMethod(), factory, handler);
    return handleRawBatchGet(resp);
}
Also used : RawBatchGetRequest(org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest) ArrayList(java.util.ArrayList) RawBatchGetResponse(org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Aggregations

ArrayList (java.util.ArrayList)2 RawBatchGetRequest (org.tikv.kvproto.Kvrpcpb.RawBatchGetRequest)2 RawBatchGetResponse (org.tikv.kvproto.Kvrpcpb.RawBatchGetResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 Histogram (io.prometheus.client.Histogram)1 RegionErrorHandler (org.tikv.common.operation.RegionErrorHandler)1