@Test
  public void testOptimize() throws IOException {
    Scan scan = new Scan();
    // A scan that just gets the first qualifier on each row of the CELL_GRID
    scan.addColumn(CF, ONE);
    try (CellGridStoreScanner scanner = new CellGridStoreScanner(scan, this.scanInfo)) {
      List<Cell> results = new ArrayList<>();
      while (scanner.next(results)) {
        continue;
      }
      // Should be four results of column 1 (though there are 5 rows in the CELL_GRID -- the
      // TWO_POINT_TWO row does not have a a column ONE.
      assertEquals(4, results.size());
      for (Cell cell : results) {
        assertTrue(Bytes.equals(ONE, 0, ONE.length, cell.getQualifierArray(),
          cell.getQualifierOffset(), cell.getQualifierLength()));
      }
      assertTrue("Optimize should do some optimizations", scanner.optimization.get() > 0);
    }
  }
Test optimize in StoreScanner. Test that we skip to the next 'block' when we it makes sense
reading the block 'index'.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreScanner.java