Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B788E10965 for ; Fri, 18 Oct 2013 19:38:01 +0000 (UTC) Received: (qmail 33368 invoked by uid 500); 18 Oct 2013 19:38:01 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 33330 invoked by uid 500); 18 Oct 2013 19:37:59 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 33319 invoked by uid 99); 18 Oct 2013 19:37:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Oct 2013 19:37:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Oct 2013 19:37:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 097EB23889BB; Fri, 18 Oct 2013 19:37:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1533605 - /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java Date: Fri, 18 Oct 2013 19:37:37 -0000 To: commits@hbase.apache.org From: larsh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131018193738.097EB23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: larsh Date: Fri Oct 18 19:37:37 2013 New Revision: 1533605 URL: http://svn.apache.org/r1533605 Log: HBASE-9747 added test (Aditya Kishore) Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java?rev=1533605&r1=1533604&r2=1533605&view=diff ============================================================================== --- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java (original) +++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java Fri Oct 18 19:37:37 2013 @@ -28,10 +28,12 @@ import java.util.Arrays; import java.util.List; import junit.framework.Assert; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp; @@ -1225,6 +1227,52 @@ public class TestFilter extends HBaseTes verifyScanFull(s, kvs); } + // HBASE-9747 + public void testFilterListWithPrefixFilter() throws IOException { + byte[] family = Bytes.toBytes("f1"); + byte[] qualifier = Bytes.toBytes("q1"); + HTableDescriptor htd = new HTableDescriptor(getName()); + htd.addFamily(new HColumnDescriptor(family)); + HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false); + HRegion testRegion = HRegion.createHRegion(info, testDir, conf, 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 results = new ArrayList(); + int resultCount = 0; + while(scanner.next(results)) { + resultCount++; + byte[] row = results.get(0).getRow(); + LOG.debug("Found row: " + Bytes.toStringBinary(row)); + Assert.assertTrue(Bytes.equals(row, Bytes.toBytes("brow")) + || Bytes.equals(row, Bytes.toBytes("crow"))); + results.clear(); + } + Assert.assertEquals(2, resultCount); + scanner.close(); + + HLog hlog = testRegion.getLog(); + testRegion.close(); + hlog.closeAndDelete(); + } + public void testNestedFilterListWithSCVF() throws IOException { byte[] columnStatus = Bytes.toBytes("S"); HTableDescriptor htd = new HTableDescriptor(getName());