hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1444972 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/filter/FilterList.java test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
Date Mon, 11 Feb 2013 21:34:00 GMT
Author: tedyu
Date: Mon Feb 11 21:34:00 2013
New Revision: 1444972

URL: http://svn.apache.org/r1444972
Log:
HBASE-6132 ColumnCountGetFilter & PageFilter not working with FilterList (Anoop)


Added:
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java
Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/FilterList.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/FilterList.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java?rev=1444972&r1=1444971&r2=1444972&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java Mon Feb
11 21:34:00 2013
@@ -253,12 +253,11 @@ public class FilterList implements Filte
   public boolean filterRow() {
     for (Filter filter : filters) {
       if (operator == Operator.MUST_PASS_ALL) {
-        if (filter.filterAllRemaining() || filter.filterRow()) {
+        if (filter.filterRow()) {
           return true;
         }
       } else if (operator == Operator.MUST_PASS_ONE) {
-        if (!filter.filterAllRemaining()
-            && !filter.filterRow()) {
+        if (!filter.filterRow()) {
           return false;
         }
       }

Added: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java?rev=1444972&view=auto
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java
(added)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/filter/TestColumnCountGetFilter.java
Mon Feb 11 21:34:00 2013
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.filter;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValueTestUtil;
+import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.InternalScanner;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SmallTests.class)
+public class TestColumnCountGetFilter {
+
+  private final static HBaseTestingUtility TEST_UTIL = new
+      HBaseTestingUtility();
+
+  @Test
+  public void testColumnCountGetFilter() throws IOException {
+    String family = "Family";
+    HTableDescriptor htd = new HTableDescriptor("testColumnCountGetFilter");
+    htd.addFamily(new HColumnDescriptor(family));
+    HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+    HRegion region = HRegion.createHRegion(info, TEST_UTIL.
+      getDataTestDir(), TEST_UTIL.getConfiguration(), htd);
+    try {
+      String valueString = "ValueString";
+      String row = "row-1";
+      List<String> columns = generateRandomWords(10000, "column");
+      Put p = new Put(Bytes.toBytes(row));
+      p.setWriteToWAL(false);
+      for (String column : columns) {
+        KeyValue kv = KeyValueTestUtil.create(row, family, column, 0, valueString);
+        p.add(kv);
+      }
+      region.put(p);
+
+      Get get = new Get(row.getBytes());
+      Filter filter = new ColumnCountGetFilter(100);
+      get.setFilter(filter);
+      Scan scan = new Scan(get);
+      InternalScanner scanner = region.getScanner(scan);
+      List<KeyValue> results = new ArrayList<KeyValue>();
+      scanner.next(results);
+      assertEquals(100, results.size());
+    } finally {
+      region.close();
+      region.getLog().closeAndDelete();
+    }
+
+    region.close();
+    region.getLog().closeAndDelete();
+  }
+
+  @Test
+  public void testColumnCountGetFilterWithFilterList() throws IOException {
+    String family = "Family";
+    HTableDescriptor htd = new HTableDescriptor("testColumnCountGetFilter");
+    htd.addFamily(new HColumnDescriptor(family));
+    HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+    HRegion region = HRegion.createHRegion(info, TEST_UTIL.
+      getDataTestDir(), TEST_UTIL.getConfiguration(), htd);
+    try {
+      String valueString = "ValueString";
+      String row = "row-1";
+      List<String> columns = generateRandomWords(10000, "column");
+      Put p = new Put(Bytes.toBytes(row));
+      p.setWriteToWAL(false);
+      for (String column : columns) {
+        KeyValue kv = KeyValueTestUtil.create(row, family, column, 0, valueString);
+        p.add(kv);
+      }
+      region.put(p);
+
+      Get get = new Get(row.getBytes());
+      FilterList filterLst = new FilterList ();
+      filterLst.addFilter( new ColumnCountGetFilter(100));
+      get.setFilter(filterLst);
+      Scan scan = new Scan(get);
+      InternalScanner scanner = region.getScanner(scan);
+      List<KeyValue> results = new ArrayList<KeyValue>();
+      scanner.next(results);
+      assertEquals(100, results.size());
+    } finally {
+      region.close();
+      region.getLog().closeAndDelete();
+    }
+
+    region.close();
+    region.getLog().closeAndDelete();
+  }
+
+  List<String> generateRandomWords(int numberOfWords, String suffix) {
+    Set<String> wordSet = new HashSet<String>();
+    for (int i = 0; i < numberOfWords; i++) {
+      int lengthOfWords = (int) (Math.random()*2) + 1;
+      char[] wordChar = new char[lengthOfWords];
+      for (int j = 0; j < wordChar.length; j++) {
+        wordChar[j] = (char) (Math.random() * 26 + 97);
+      }
+      String word;
+      if (suffix == null) {
+        word = new String(wordChar);
+      } else {
+        word = new String(wordChar) + suffix;
+      }
+      wordSet.add(word);
+    }
+    List<String> wordList = new ArrayList<String>(wordSet);
+    return wordList;
+  }
+
+  @org.junit.Rule
+  public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
+    new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
+}
+

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=1444972&r1=1444971&r2=1444972&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 Mon
Feb 11 21:34:00 2013
@@ -104,7 +104,6 @@ public class TestFilterList extends Test
     /* We should filter any row */
     rowkey = Bytes.toBytes("z");
     assertTrue(filterMPONE.filterRowKey(rowkey, 0, rowkey.length));
-    assertTrue(filterMPONE.filterRow());
     assertTrue(filterMPONE.filterAllRemaining());
 
   }
@@ -146,9 +145,6 @@ public class TestFilterList extends Test
     // Should fail here; row should be filtered out.
     KeyValue kv = new KeyValue(rowkey, rowkey, rowkey, rowkey);
     assertTrue(Filter.ReturnCode.NEXT_ROW == filterMPALL.filterKeyValue(kv));
-
-    // Both filters in Set should be satisfied by now
-    assertTrue(filterMPALL.filterRow());
   }
 
   /**



Mime
View raw message