@Override
  public Result[] addAndGet(Result[] results, boolean isHeartbeatMessage) throws IOException {
    // If no results were returned it indicates that either we have the all the partial results
    // necessary to construct the complete result or the server had to send a heartbeat message
    // to the client to keep the client-server connection alive
    if (results.length == 0) {
      // If this response was an empty heartbeat message, then we have not exhausted the region
      // and thus there may be more partials server side that still need to be added to the partial
      // list before we form the complete Result
      if (!partialResults.isEmpty() && !isHeartbeatMessage) {
        return updateNumberOfCompleteResultsAndReturn(combine());
      }
      return EMPTY_RESULT_ARRAY;
    }
    // In every RPC response there should be at most a single partial result. Furthermore, if
    // there is a partial result, it is guaranteed to be in the last position of the array.
    Result last = results[results.length - 1];
    if (last.mayHaveMoreCellsInRow()) {
      if (partialResults.isEmpty()) {
        partialResults.add(last);
        return updateNumberOfCompleteResultsAndReturn(Arrays.copyOf(results, results.length - 1));
      }
      // We have only one result and it is partial
      if (results.length == 1) {
        // check if there is a row change
        if (Bytes.equals(partialResults.get(0).getRow(), last.getRow())) {
          partialResults.add(last);
          return EMPTY_RESULT_ARRAY;
        }
        Result completeResult = combine();
        partialResults.add(last);
        return updateNumberOfCompleteResultsAndReturn(completeResult);
      }
      // We have some complete results
      Result[] resultsToReturn = prependCombined(results, results.length - 1);
      partialResults.add(last);
      return updateNumberOfCompleteResultsAndReturn(resultsToReturn);
    }
    if (!partialResults.isEmpty()) {
      return updateNumberOfCompleteResultsAndReturn(prependCombined(results, results.length));
    }
    return updateNumberOfCompleteResultsAndReturn(results);
  }
A scan result cache that only returns complete result.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/CompleteScanResultCache.java