@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)); }
@Override public ReturnCode filterKeyValue(KeyValue next) { if (this.done) { return ReturnCode.SKIP; } switch (KeyValue.Type.codeToType(next.getType())) { case DeleteFamily: this.coveringDelete.reset(); this.coveringDelete.deleteFamily = next; return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = next; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = next; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(next)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(next)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(next)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; }
ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(KeyValue next) { if (this.done) { return ReturnCode.SKIP; } switch (KeyValue.Type.codeToType(next.getType())) { case DeleteFamily: this.coveringDelete.reset(); this.coveringDelete.deleteFamily = next; return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = next; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = next; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(next)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(next)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(next)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; } }
ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(KeyValue next) { if (this.done) { return ReturnCode.SKIP; } switch (KeyValue.Type.codeToType(next.getType())) { case DeleteFamily: this.coveringDelete.reset(); this.coveringDelete.deleteFamily = next; return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = next; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = next; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(next)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(next)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(next)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; } ApplyAndFilterDeletesFilter(Set<ImmutableBytesPtr> families); }
ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(KeyValue next) { if (this.done) { return ReturnCode.SKIP; } switch (KeyValue.Type.codeToType(next.getType())) { case DeleteFamily: this.coveringDelete.reset(); this.coveringDelete.deleteFamily = next; return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = next; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = next; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(next)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(next)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(next)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; } ApplyAndFilterDeletesFilter(Set<ImmutableBytesPtr> families); @Override void reset(); @Override KeyValue getNextKeyHint(KeyValue peeked); @Override ReturnCode filterKeyValue(KeyValue next); @Override void write(DataOutput out); @Override void readFields(DataInput in); }
ApplyAndFilterDeletesFilter extends FilterBase { @Override public ReturnCode filterKeyValue(KeyValue next) { if (this.done) { return ReturnCode.SKIP; } switch (KeyValue.Type.codeToType(next.getType())) { case DeleteFamily: this.coveringDelete.reset(); this.coveringDelete.deleteFamily = next; return ReturnCode.SKIP; case DeleteColumn: this.coveringDelete.pointDelete = null; this.coveringDelete.deleteColumn = next; return ReturnCode.SKIP; case Delete: this.coveringDelete.pointDelete = next; return ReturnCode.SKIP; default: if (coveringDelete.empty()) { return ReturnCode.INCLUDE; } if (coveringDelete.matchesFamily(next)) { this.currentHint = familyHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesColumn(next)) { this.currentHint = columnHint; return ReturnCode.SEEK_NEXT_USING_HINT; } if (coveringDelete.matchesPoint(next)) { return ReturnCode.SKIP; } } return ReturnCode.INCLUDE; } ApplyAndFilterDeletesFilter(Set<ImmutableBytesPtr> families); @Override void reset(); @Override KeyValue getNextKeyHint(KeyValue peeked); @Override ReturnCode filterKeyValue(KeyValue next); @Override void write(DataOutput out); @Override void readFields(DataInput in);  }