You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/10/18 21:40:32 UTC

svn commit: r1533610 - /hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java

Author: larsh
Date: Fri Oct 18 19:40:31 2013
New Revision: 1533610

URL: http://svn.apache.org/r1533610
Log:
HBASE-9747 added test (Aditya Kishore)

Modified:
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java?rev=1533610&r1=1533609&r2=1533610&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java (original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java Fri Oct 18 19:40:31 2013
@@ -1254,6 +1254,54 @@ public class TestFilter {
     verifyScanFull(s, kvs);
   }
 
+  // HBASE-9747
+  @Test
+  public void testFilterListWithPrefixFilter() throws IOException {
+    byte[] family = Bytes.toBytes("f1");
+    byte[] qualifier = Bytes.toBytes("q1");
+    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestFilter"));
+    htd.addFamily(new HColumnDescriptor(family));
+    HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
+    HRegion testRegion = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(),
+        TEST_UTIL.getConfiguration(), htd);
+
+    for(int i=0; i<5; i++) {
+      Put p = new Put(Bytes.toBytes((char)('a'+i) + "row"));
+      p.setDurability(Durability.SKIP_WAL);
+      p.add(family, qualifier, Bytes.toBytes(String.valueOf(111+i)));
+      testRegion.put(p);
+    }
+    testRegion.flushcache();
+
+    // rows starting with "b"
+    PrefixFilter pf = new PrefixFilter(new byte[] {'b'}) ;
+    // rows with value of column 'q1' set to '113'
+    SingleColumnValueFilter scvf = new SingleColumnValueFilter(
+        family, qualifier, CompareOp.EQUAL, Bytes.toBytes("113"));
+    // combine these two with OR in a FilterList
+    FilterList filterList = new FilterList(Operator.MUST_PASS_ONE, pf, scvf);
+
+    Scan s1 = new Scan();
+    s1.setFilter(filterList);
+    InternalScanner scanner = testRegion.getScanner(s1);
+    List<Cell> results = new ArrayList<Cell>();
+    int resultCount = 0;
+    while(scanner.next(results)) {
+      resultCount++;
+      byte[] row =  CellUtil.cloneRow(results.get(0));
+      LOG.debug("Found row: " + Bytes.toStringBinary(row));
+      assertTrue(Bytes.equals(row, Bytes.toBytes("brow"))
+          || Bytes.equals(row, Bytes.toBytes("crow")));
+      results.clear();
+    }
+    assertEquals(2, resultCount);
+    scanner.close();
+
+    HLog hlog = testRegion.getLog();
+    testRegion.close();
+    hlog.closeAndDelete();
+  }
+
   @Test
   public void testSingleColumnValueFilter() throws IOException {