Search in sources :

Example 1 with RawScanRequest

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

the class RegionStoreClient method rawScan.

/**
 * Return a batch KvPair list containing limited key-value pairs starting from `key`, which are in
 * the same region
 *
 * @param backOffer BackOffer
 * @param key startKey
 * @param keyOnly true if value of KvPair is not needed
 * @return KvPair list
 */
public List<KvPair> rawScan(BackOffer backOffer, ByteString key, int limit, boolean keyOnly) {
    Supplier<RawScanRequest> factory = () -> RawScanRequest.newBuilder().setContext(region.getContext()).setStartKey(key).setKeyOnly(keyOnly).setLimit(limit).build();
    KVErrorHandler<RawScanResponse> handler = new KVErrorHandler<>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
    RawScanResponse resp = callWithRetry(backOffer, TikvGrpc.getRawScanMethod(), factory, handler);
    return rawScanHelper(resp);
}
Also used : RawScanResponse(org.tikv.kvproto.Kvrpcpb.RawScanResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler) RawScanRequest(org.tikv.kvproto.Kvrpcpb.RawScanRequest)

Example 2 with RawScanRequest

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

the class RegionStoreClient method rawScan.

/**
 * Return a batch KvPair list containing limited key-value pairs starting from `key`, which are in
 * the same region
 *
 * @param backOffer BackOffer
 * @param key startKey
 * @param keyOnly true if value of KvPair is not needed
 * @return KvPair list
 */
public List<KvPair> rawScan(BackOffer backOffer, ByteString key, int limit, boolean keyOnly) {
    Long clusterId = pdClient.getClusterId();
    Histogram.Timer requestTimer = GRPC_RAW_REQUEST_LATENCY.labels("client_grpc_raw_scan", clusterId.toString()).startTimer();
    try {
        Supplier<RawScanRequest> factory = () -> RawScanRequest.newBuilder().setContext(makeContext(storeType, backOffer.getSlowLog())).setStartKey(key).setKeyOnly(keyOnly).setLimit(limit).build();
        RegionErrorHandler<RawScanResponse> handler = new RegionErrorHandler<RawScanResponse>(regionManager, this, resp -> resp.hasRegionError() ? resp.getRegionError() : null);
        RawScanResponse resp = callWithRetry(backOffer, TikvGrpc.getRawScanMethod(), factory, handler);
        return rawScanHelper(resp);
    } finally {
        requestTimer.observeDuration();
    }
}
Also used : Histogram(io.prometheus.client.Histogram) RawScanResponse(org.tikv.kvproto.Kvrpcpb.RawScanResponse) RawScanRequest(org.tikv.kvproto.Kvrpcpb.RawScanRequest) RegionErrorHandler(org.tikv.common.operation.RegionErrorHandler)

Aggregations

RawScanRequest (org.tikv.kvproto.Kvrpcpb.RawScanRequest)2 RawScanResponse (org.tikv.kvproto.Kvrpcpb.RawScanResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 Histogram (io.prometheus.client.Histogram)1 RegionErrorHandler (org.tikv.common.operation.RegionErrorHandler)1