Search in sources :

Example 1 with ScanRequest

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

the class RegionStoreClient method scan.

public List<KvPair> scan(BackOffer backOffer, ByteString startKey, long version, boolean keyOnly) {
    boolean forWrite = false;
    while (true) {
        // we should refresh region
        region = regionManager.getRegionByKey(startKey, backOffer);
        Supplier<ScanRequest> request = () -> ScanRequest.newBuilder().setContext(makeContext(getResolvedLocks(version), this.storeType, backOffer.getSlowLog())).setStartKey(startKey).setVersion(version).setKeyOnly(keyOnly).setLimit(getConf().getScanBatchSize()).build();
        KVErrorHandler<ScanResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
        ScanResponse resp = callWithRetry(backOffer, TikvGrpc.getKvScanMethod(), request, handler);
        if (isScanSuccess(backOffer, resp)) {
            return doScan(resp);
        }
    }
}
Also used : RawScanRequest(org.tikv.kvproto.Kvrpcpb.RawScanRequest) ScanRequest(org.tikv.kvproto.Kvrpcpb.ScanRequest) RawScanResponse(org.tikv.kvproto.Kvrpcpb.RawScanResponse) ScanResponse(org.tikv.kvproto.Kvrpcpb.ScanResponse) KVErrorHandler(org.tikv.common.operation.KVErrorHandler)

Example 2 with ScanRequest

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

the class RegionStoreClient method scan.

public List<KvPair> scan(BackOffer backOffer, ByteString startKey, int limit, long version, boolean keyOnly) {
    boolean forWrite = false;
    while (true) {
        Supplier<ScanRequest> request = () -> ScanRequest.newBuilder().setContext(region.getContext(getResolvedLocks(version))).setStartKey(startKey).setVersion(version).setKeyOnly(keyOnly).setLimit(limit).build();
        KVErrorHandler<ScanResponse> handler = new KVErrorHandler<>(regionManager, this, lockResolverClient, resp -> resp.hasRegionError() ? resp.getRegionError() : null, resp -> null, resolveLockResult -> addResolvedLocks(version, resolveLockResult.getResolvedLocks()), version, forWrite);
        ScanResponse resp = callWithRetry(backOffer, TikvGrpc.getKvScanMethod(), request, handler);
        if (isScanSuccess(backOffer, resp)) {
            return doScan(resp);
        }
        // we should refresh region
        region = regionManager.getRegionByKey(startKey);
    }
}
Also used : ScanRequest(org.tikv.kvproto.Kvrpcpb.ScanRequest) RawScanRequest(org.tikv.kvproto.Kvrpcpb.RawScanRequest) ScanResponse(org.tikv.kvproto.Kvrpcpb.ScanResponse) RawScanResponse(org.tikv.kvproto.Kvrpcpb.RawScanResponse) KVErrorHandler(com.pingcap.tikv.operation.KVErrorHandler)

Aggregations

RawScanRequest (org.tikv.kvproto.Kvrpcpb.RawScanRequest)2 RawScanResponse (org.tikv.kvproto.Kvrpcpb.RawScanResponse)2 ScanRequest (org.tikv.kvproto.Kvrpcpb.ScanRequest)2 ScanResponse (org.tikv.kvproto.Kvrpcpb.ScanResponse)2 KVErrorHandler (com.pingcap.tikv.operation.KVErrorHandler)1 KVErrorHandler (org.tikv.common.operation.KVErrorHandler)1