@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, 0, qual2.length, 11, Type.Put, value, 0, value.length); 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)); }
@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);  }