hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1567426 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
Date Tue, 11 Feb 2014 22:32:36 GMT
Author: tedyu
Date: Tue Feb 11 22:32:36 2014
New Revision: 1567426

URL: http://svn.apache.org/r1567426
Log:
HBASE-10493 InclusiveStopFilter#filterKeyValue() should perform filtering on row key


Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java?rev=1567426&r1=1567425&r2=1567426&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
Tue Feb 11 22:32:36 2014
@@ -53,6 +53,12 @@ public class InclusiveStopFilter extends
     return this.stopRowKey;
   }
 
+  @Override
+  public ReturnCode filterKeyValue(KeyValue v) {
+    if (done) return ReturnCode.NEXT_ROW;
+    return ReturnCode.INCLUDE;
+  }
+
   public boolean filterRowKey(byte[] buffer, int offset, int length) {
     if (buffer == null) {
       //noinspection RedundantIfStatement

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java?rev=1567426&r1=1567425&r2=1567426&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java Tue
Feb 11 22:32:36 2014
@@ -19,6 +19,8 @@
  */
 package org.apache.hadoop.hbase.filter;
 
+import static org.junit.Assert.assertEquals;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInput;
@@ -205,6 +207,43 @@ public class TestFilterList extends Test
     }
   }
 
+  public static class AlwaysNextColFilter extends FilterBase {
+    public AlwaysNextColFilter() {
+      super();
+    }
+    @Override
+    public ReturnCode filterKeyValue(KeyValue v) {
+      return ReturnCode.NEXT_COL;
+    }
+    @Override
+    public void readFields(DataInput arg0) throws IOException {}
+
+    @Override
+    public void write(DataOutput arg0) throws IOException {}
+  }
+
+  /**
+   * 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);
+  }
+
   /**
    * Test serialization
    * @throws Exception



Mime
View raw message