private void testRowsSeenMetric(Scan baseScan) throws Exception {
    Scan scan;
    scan = new Scan(baseScan);
    testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, NUM_ROWS);

    for (int i = 0; i < ROWS.length - 1; i++) {
      scan = new Scan(baseScan);
      scan.withStartRow(ROWS[0]);
      scan.withStopRow(ROWS[i + 1]);
      testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, i + 1);
    }

    for (int i = ROWS.length - 1; i > 0; i--) {
      scan = new Scan(baseScan);
      scan.withStartRow(ROWS[i - 1]);
      scan.withStopRow(ROWS[ROWS.length - 1]);
      testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME,
        ROWS.length - i);
    }

    // The filter should filter out all rows, but we still expect to see every row.
    Filter filter =
      new RowFilter(CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("xyz")));
    scan = new Scan(baseScan);
    scan.setFilter(filter);
    testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);

    // Filter should pass on all rows
    SingleColumnValueFilter singleColumnValueFilter =
      new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOperator.EQUAL, VALUE);
    scan = new Scan(baseScan);
    scan.setFilter(singleColumnValueFilter);
    testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);

    // Filter should filter out all rows
    singleColumnValueFilter =
      new SingleColumnValueFilter(FAMILIES[0], QUALIFIERS[0], CompareOperator.NOT_EQUAL, VALUE);
    scan = new Scan(baseScan);
    scan.setFilter(singleColumnValueFilter);
    testMetric(scan, ServerSideScanMetrics.COUNT_OF_ROWS_SCANNED_KEY_METRIC_NAME, ROWS.length);
  }
@return The approximate heap size of a cell in the test table. All cells should have
        approximately the same heap size, so the value is cached to avoid repeating the
        calculation
@throws Exception on unexpected failure
hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerSideScanMetricsFromClientSide.java