@Test
  public void testHeartbeatWithSparseCellFilter() throws Exception {
    testImportanceOfHeartbeats(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        Scan scan = new Scan();
        scan.setMaxResultSize(Long.MAX_VALUE);
        scan.setCaching(Integer.MAX_VALUE);
        scan.setFilter(new SparseCellFilter());
        try (ScanPerNextResultScanner scanner =
          new ScanPerNextResultScanner(CONN.getTable(TABLE_NAME), scan)) {
          int num = 0;
          while (scanner.next() != null) {
            num++;
          }
          assertEquals(1, num);
        }

        scan = new Scan();
        scan.setMaxResultSize(Long.MAX_VALUE);
        scan.setCaching(Integer.MAX_VALUE);
        scan.setFilter(new SparseCellFilter());
        scan.setAllowPartialResults(true);
        try (ScanPerNextResultScanner scanner =
          new ScanPerNextResultScanner(CONN.getTable(TABLE_NAME), scan)) {
          int num = 0;
          while (scanner.next() != null) {
            num++;
          }
          assertEquals(NUM_FAMILIES * NUM_QUALIFIERS, num);
        }

        return null;
      }
    });
  }
Test the case that there is a filter which filters most of cells
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerHeartbeatMessages.java