use of com.pingcap.tidb.tipb.EncodeType in project tispark by pingcap.
the class DAGIterator method process.
private SelectResponse process(RangeSplitter.RegionTask regionTask) {
Queue<RangeSplitter.RegionTask> remainTasks = new ArrayDeque<>();
Queue<SelectResponse> responseQueue = new ArrayDeque<>();
remainTasks.add(regionTask);
BackOffer backOffer = ConcreteBackOffer.newCopNextMaxBackOff();
HashSet<Long> resolvedLocks = new HashSet<>();
// the remaining tasks.
while (!remainTasks.isEmpty()) {
RangeSplitter.RegionTask task = remainTasks.poll();
if (task == null) {
continue;
}
List<Coprocessor.KeyRange> ranges = task.getRanges();
TiRegion region = task.getRegion();
Metapb.Store store = task.getStore();
try {
RegionStoreClient client = session.getRegionStoreClientBuilder().build(region, store, storeType);
client.addResolvedLocks(startTs, resolvedLocks);
Collection<RangeSplitter.RegionTask> tasks = client.coprocess(backOffer, dagRequest, region, ranges, responseQueue, startTs);
if (tasks != null) {
remainTasks.addAll(tasks);
}
resolvedLocks.addAll(client.getResolvedLocks(startTs));
} catch (Throwable e) {
// Handle region task failed
logger.error("Process region tasks failed, remain " + remainTasks.size() + " tasks not executed due to", e);
// Rethrow to upper levels
throw new RegionTaskException("Handle region task failed:", e);
}
}
// Add all chunks to the final result
List<Chunk> resultChunk = new ArrayList<>();
EncodeType encodeType = null;
while (!responseQueue.isEmpty()) {
SelectResponse response = responseQueue.poll();
if (response != null) {
encodeType = response.getEncodeType();
resultChunk.addAll(response.getChunksList());
}
}
return SelectResponse.newBuilder().addAllChunks(resultChunk).setEncodeType(encodeType).build();
}
use of com.pingcap.tidb.tipb.EncodeType in project client-java by tikv.
the class DAGIterator method process.
private SelectResponse process(RangeSplitter.RegionTask regionTask) {
Queue<RangeSplitter.RegionTask> remainTasks = new ArrayDeque<>();
Queue<SelectResponse> responseQueue = new ArrayDeque<>();
remainTasks.add(regionTask);
BackOffer backOffer = ConcreteBackOffer.newCopNextMaxBackOff();
HashSet<Long> resolvedLocks = new HashSet<>();
// the remaining tasks.
while (!remainTasks.isEmpty()) {
RangeSplitter.RegionTask task = remainTasks.poll();
if (task == null) {
continue;
}
List<Coprocessor.KeyRange> ranges = task.getRanges();
TiRegion region = task.getRegion();
TiStore store = task.getStore();
try {
RegionStoreClient client = session.getRegionStoreClientBuilder().build(region, store, storeType);
client.addResolvedLocks(startTs, resolvedLocks);
Collection<RangeSplitter.RegionTask> tasks = client.coprocess(backOffer, dagRequest, ranges, responseQueue, startTs);
if (tasks != null) {
remainTasks.addAll(tasks);
}
resolvedLocks.addAll(client.getResolvedLocks(startTs));
} catch (Throwable e) {
// Handle region task failed
logger.error("Process region tasks failed, remain " + remainTasks.size() + " tasks not executed due to", e);
// Rethrow to upper levels
throw new RegionTaskException("Handle region task failed:", e);
}
}
// Add all chunks to the final result
List<Chunk> resultChunk = new ArrayList<>();
EncodeType encodeType = null;
while (!responseQueue.isEmpty()) {
SelectResponse response = responseQueue.poll();
if (response != null) {
encodeType = response.getEncodeType();
resultChunk.addAll(response.getChunksList());
}
}
return SelectResponse.newBuilder().addAllChunks(resultChunk).setEncodeType(encodeType).build();
}
Aggregations