Skip to content

Commit

Permalink
fix count error, if advanceNextResponse is empty, we should read next…
Browse files Browse the repository at this point in the history
… region (pingcap#878)
  • Loading branch information
marsishandsome committed Jul 4, 2019
1 parent 0476da9 commit 1267e3d
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,27 @@ private boolean advanceNextResponse() {
return true;
}

/**
* chunk maybe empty while there is still data transmitting from TiKV. In this case, {@code
* readNextRegionChunks} cannot just returns false because the iterator thinks there is no data to
* process. This while loop ensures we can drain all possible data transmitting from TiKV.
*
* @return
*/
private boolean readNextRegionChunks() {
if (eof || regionTasks == null || taskIndex >= regionTasks.size()) {
return false;
while (hasNextRegionTask()) {
if (doReadNextRegionChunks()) {
return true;
}
}
return false;
}

private boolean hasNextRegionTask() {
return !(eof || regionTasks == null || taskIndex >= regionTasks.size());
}

private boolean doReadNextRegionChunks() {
try {
switch (pushDownType) {
case STREAMING:
Expand Down

0 comments on commit 1267e3d

Please sign in to comment.