@Test
  public void testRawScan() throws Exception {
    TableDescriptor htd = hbu.createTableDescriptor(TableName.valueOf(name.getMethodName()), 0, 3,
      HConstants.FOREVER, KeepDeletedCells.TRUE);
    Region region = hbu.createLocalHRegion(htd, null, null);

    long ts = EnvironmentEdgeManager.currentTime();
    Put p = new Put(T1, ts);
    p.addColumn(c0, c0, T1);
    region.put(p);
    p = new Put(T1, ts + 2);
    p.addColumn(c0, c0, T2);
    region.put(p);
    p = new Put(T1, ts + 4);
    p.addColumn(c0, c0, T3);
    region.put(p);

    Delete d = new Delete(T1, ts + 1);
    region.delete(d);

    d = new Delete(T1, ts + 2);
    d.addColumn(c0, c0, ts + 2);
    region.delete(d);

    d = new Delete(T1, ts + 3);
    d.addColumns(c0, c0, ts + 3);
    region.delete(d);

    Scan s = new Scan();
    s.setRaw(true);
    s.readAllVersions();
    InternalScanner scan = region.getScanner(s);
    List<ExtendedCell> kvs = new ArrayList<>();
    scan.next(kvs);
    assertEquals(8, kvs.size());
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(0)));
    assertArrayEquals(CellUtil.cloneValue(kvs.get(1)), T3);
    assertTrue(CellUtil.isDelete(kvs.get(2)));
    assertTrue(CellUtil.isDelete(kvs.get(3))); // .isDeleteType());
    assertArrayEquals(CellUtil.cloneValue(kvs.get(4)), T2);
    assertArrayEquals(CellUtil.cloneValue(kvs.get(5)), T1);
    // we have 3 CFs, so there are two more delete markers
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(6)));
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(7)));

    // verify that raw scans honor the passed timerange
    s = new Scan();
    s.setRaw(true);
    s.readAllVersions();
    s.setTimeRange(0, 1);
    scan = region.getScanner(s);
    kvs = new ArrayList<>();
    scan.next(kvs);
    // nothing in this interval, not even delete markers
    assertTrue(kvs.isEmpty());

    // filter new delete markers
    s = new Scan();
    s.setRaw(true);
    s.readAllVersions();
    s.setTimeRange(0, ts + 2);
    scan = region.getScanner(s);
    kvs = new ArrayList<>();
    scan.next(kvs);
    assertEquals(4, kvs.size());
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(0)));
    assertArrayEquals(CellUtil.cloneValue(kvs.get(1)), T1);
    // we have 3 CFs
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(2)));
    assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(3)));

    // filter old delete markers
    s = new Scan();
    s.setRaw(true);
    s.readAllVersions();
    s.setTimeRange(ts + 3, ts + 5);
    scan = region.getScanner(s);
    kvs = new ArrayList<>();
    scan.next(kvs);
    assertEquals(2, kvs.size());
    assertArrayEquals(CellUtil.cloneValue(kvs.get(0)), T3);
    assertTrue(CellUtil.isDelete(kvs.get(1)));

    HBaseTestingUtil.closeRegionAndWAL(region);
  }
Verify that "raw" scanning mode return delete markers and deletes rows.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java