public static int countRows(final Table table, final Scan scan) throws IOException {
    try (ResultScanner results = table.getScanner(scan)) {
      int count = 0;
      while (results.next() != null) {
        count++;
      }
      return count;
    }
  }
Return the number of rows in the given table.
@param table to count rows
@return count of rows
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseTestingUtility.java