diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java index b938ec5d6c2..2c03067768e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java @@ -24,7 +24,9 @@ import java.util.ArrayList; import com.google.protobuf.HBaseZeroCopyByteString; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.exceptions.DeserializationException; +import org.apache.hadoop.hbase.filter.Filter.ReturnCode; import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; import org.apache.hadoop.hbase.util.Bytes; @@ -51,6 +53,12 @@ public class InclusiveStopFilter extends FilterBase { return this.stopRowKey; } + @Override + public ReturnCode filterKeyValue(Cell v) { + if (done) return ReturnCode.NEXT_ROW; + return ReturnCode.INCLUDE; + } + public boolean filterRowKey(byte[] buffer, int offset, int length) { if (buffer == null) { //noinspection RedundantIfStatement diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java index 945b4900816..a51d5a4b4d4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java @@ -294,6 +294,28 @@ public class TestFilterList { assertEquals(flist.filterKeyValue(new KeyValue(r2,r2,r2)), ReturnCode.SKIP); } + /** + * When we do a "MUST_PASS_ONE" (a logical 'OR') of the two filters + * we expect to get the same result as the inclusive stop result. + * @throws Exception + */ + public void testFilterListWithInclusiveStopFilteMustPassOne() throws Exception { + byte[] r1 = Bytes.toBytes("Row1"); + byte[] r11 = Bytes.toBytes("Row11"); + byte[] r2 = Bytes.toBytes("Row2"); + + FilterList flist = new FilterList(FilterList.Operator.MUST_PASS_ONE); + flist.addFilter(new AlwaysNextColFilter()); + flist.addFilter(new InclusiveStopFilter(r1)); + flist.filterRowKey(r1, 0, r1.length); + assertEquals(flist.filterKeyValue(new KeyValue(r1,r1,r1)), ReturnCode.INCLUDE); + assertEquals(flist.filterKeyValue(new KeyValue(r11,r11,r11)), ReturnCode.INCLUDE); + + flist.reset(); + flist.filterRowKey(r2, 0, r2.length); + assertEquals(flist.filterKeyValue(new KeyValue(r2,r2,r2)), ReturnCode.SKIP); + } + public static class AlwaysNextColFilter extends FilterBase { public AlwaysNextColFilter() { super();