private Result regroupResults(Result result) {
    partialResults.addLast(result);
    numCellsOfPartialResults += result.size();
    if (numCellsOfPartialResults < batch) {
      return null;
    }
    ExtendedCell[] cells = new ExtendedCell[batch];
    int cellCount = 0;
    boolean stale = false;
    for (;;) {
      Result r = partialResults.pollFirst();
      stale = stale || r.isStale();
      int newCellCount = cellCount + r.size();
      if (newCellCount > batch) {
        // We have more cells than expected, so split the current result
        int len = batch - cellCount;
        System.arraycopy(r.rawCells(), 0, cells, cellCount, len);
        ExtendedCell[] remainingCells = new ExtendedCell[r.size() - len];
        System.arraycopy(r.rawExtendedCells(), len, remainingCells, 0, r.size() - len);
        partialResults.addFirst(
          Result.create(remainingCells, r.getExists(), r.isStale(), r.mayHaveMoreCellsInRow()));
        break;
      }
      System.arraycopy(r.rawCells(), 0, cells, cellCount, r.size());
      if (newCellCount == batch) {
        break;
      }
      cellCount = newCellCount;
    }
    numCellsOfPartialResults -= batch;
    return Result.create(cells, null, stale,
      result.mayHaveMoreCellsInRow() || !partialResults.isEmpty());
  }
A scan result cache for batched scan, i.e,
{@code scan.getBatch() > 0 && !scan.getAllowPartialResults()}.
<p>
If user setBatch(5) and rpc returns 3+5+5+5+3 cells, we should return 5+5+5+5+1 to user. setBatch
doesn't mean setAllowPartialResult(true).
@since 2.0.0
hbase-client/src/main/java/org/apache/hadoop/hbase/client/BatchScanResultCache.java