### Question:
ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(Cell next) { KeyValue nextKV = PhoenixKeyValueUtil.maybeCopyCell(next); switch (KeyValue.Type.codeToType(next.getTypeByte())) { case DeleteFamily: if (coveringDelete.deleteFamily == null || !CellUtil.matchingFamily(coveringDelete.deleteFamily, nextKV)) { this.coveringDelete.reset(); this.coveringDelete.deleteFamily = nextKV; } return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = nextKV; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = nextKV; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(nextKV)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(nextKV)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(nextKV)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; } ApplyAndFilterDeletesFilter(Set<ImmutableBytesPtr> families); DeleteTracker getDeleteTracker(); @Override void reset(); @Override Cell getNextCellHint(Cell peeked); @Override ReturnCode filterKeyValue(Cell next);  }### Answer:
@Test public void testCoveringPointDelete() { KeyValue kv = createKvForType(Type.Delete); ApplyAndFilterDeletesFilter filter = new ApplyAndFilterDeletesFilter(EMPTY_SET); filter.filterKeyValue(kv); KeyValue put = createKvForType(Type.Put); assertEquals("Didn't filter out put with same timestamp!", ReturnCode.SKIP, filter.filterKeyValue(put)); assertEquals("Didn't filter out put with same timestamp on second call!", ReturnCode.SKIP, filter.filterKeyValue(put)); put = createKvForType(Type.Put, ts - 1); assertEquals("Didn't accept put that has an earlier ts than the covering delete!", ReturnCode.INCLUDE, filter.filterKeyValue(put)); }
@Test public void testDeleteColumnCorrectlyCoversColumns() { ApplyAndFilterDeletesFilter filter = new ApplyAndFilterDeletesFilter(EMPTY_SET); KeyValue d = createKvForType(Type.DeleteColumn, 12); byte[] qual2 = Bytes.add(qualifier, Bytes.toBytes("-other")); KeyValue put = new KeyValue(row, family, qual2, 11, Type.Put, value); assertEquals("Didn't filter out delete column", ReturnCode.SKIP, filter.filterKeyValue(d)); assertEquals("Filtered out put with different column than the delete", ReturnCode.INCLUDE, filter.filterKeyValue(put)); d = createKvForType(Type.DeleteFamily, 10); assertEquals("Didn't filter out delete column", ReturnCode.SKIP, filter.filterKeyValue(d)); d = createKvForType(Type.DeleteColumn, 11); assertEquals("Didn't filter out delete column", ReturnCode.SKIP, filter.filterKeyValue(d)); assertEquals("Filtered out put with different column than the delete", ReturnCode.INCLUDE, filter.filterKeyValue(put)); }