private int getKeyValueCount(Table table) throws IOException {
    Scan scan = new Scan();
    scan.readVersions(Integer.MAX_VALUE - 1);

    ResultScanner results = table.getScanner(scan);
    int count = 0;
    for (Result res : results) {
      count += res.listCells().size();
      System.out.println(count + ") " + res);
    }
    results.close();

    return count;
  }
Count the number of keyvalue in the table. Scans all possible versions
@param table table to scan
@return number of keyvalues over all rows in the table
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestOpenTableInCoprocessor.java