private void resetQueryMatcher(ExtendedCell lastTopKey) {
    // Reset the state of the Query Matcher and set to top row.
    // Only reset and call setRow if the row changes; avoids confusing the
    // query matcher if scanning intra-row.
    ExtendedCell cell = heap.peek();
    if (cell == null) {
      cell = lastTopKey;
    }
    if ((matcher.currentRow() == null) || !CellUtil.matchingRows(cell, matcher.currentRow())) {
      this.countPerRow = 0;
      // The setToNewRow will call reset internally
      matcher.setToNewRow(cell);
    }
  }
Returns if top of heap has changed (and KeyValueHeap has to try the next KV)
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java