@Override
  public boolean next(List<? super ExtendedCell> result, ScannerContext scannerContext)
    throws IOException {
    if (this.current == null) {
      return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
    }
    InternalScanner currentAsInternal = (InternalScanner) this.current;
    boolean moreCells = currentAsInternal.next(result, scannerContext);
    Cell pee = this.current.peek();

    /*
     * By definition, any InternalScanner must return false only when it has no further rows to be
     * fetched. So, we can close a scanner if it returns false. All existing implementations seem to
     * be fine with this. It is much more efficient to close scanners which are not needed than keep
     * them in the heap. This is also required for certain optimizations.
     */

    if (pee == null || !moreCells) {
      // add the scanner that is to be closed
      this.scannersForDelayedClose.add(this.current);
    } else {
      this.heap.add(this.current);
    }
    this.current = null;
    this.current = pollRealKV();
    if (this.current == null) {
      moreCells = scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
    }
    return moreCells;
  }
Gets the next row of keys from the top-most scanner.
<p>
This method takes care of updating the heap.
<p>
This can ONLY be called when you are using Scanners that implement InternalScanner as well as
KeyValueScanner (a {@link StoreScanner}).
@return true if more rows exist after this one, false if scanner is done
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java