hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1366198 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/filter/FilterList.java test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
Date Thu, 26 Jul 2012 20:53:17 GMT
Author: tedyu
Date: Thu Jul 26 20:53:17 2012
New Revision: 1366198

URL: http://svn.apache.org/viewvc?rev=1366198&view=rev
Log:
HBASE-6431 Some FilterList Constructors break addFilter (Alex Newman)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java?rev=1366198&r1=1366197&r2=1366198&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
Thu Jul 26 20:53:17 2012
@@ -74,7 +74,11 @@ public class FilterList implements Filte
    * @param rowFilters list of filters
    */
   public FilterList(final List<Filter> rowFilters) {
-    this.filters = rowFilters;
+    if (rowFilters instanceof ArrayList) {
+      this.filters = rowFilters;
+    } else {
+      this.filters = new ArrayList<Filter>(rowFilters);
+    }
   }
 
   /**
@@ -83,7 +87,7 @@ public class FilterList implements Filte
    * @param rowFilters
    */
   public FilterList(final Filter... rowFilters) {
-    this.filters = Arrays.asList(rowFilters);
+    this.filters = new ArrayList<Filter>(Arrays.asList(rowFilters));
   }
 
   /**
@@ -102,7 +106,7 @@ public class FilterList implements Filte
    * @param rowFilters Set of row filters.
    */
   public FilterList(final Operator operator, final List<Filter> rowFilters) {
-    this.filters = rowFilters;
+    this.filters = new ArrayList<Filter>(rowFilters);
     this.operator = operator;
   }
 
@@ -113,7 +117,7 @@ public class FilterList implements Filte
    * @param rowFilters Filters to use
    */
   public FilterList(final Operator operator, final Filter... rowFilters) {
-    this.filters = Arrays.asList(rowFilters);
+    this.filters = new ArrayList<Filter>(Arrays.asList(rowFilters));
     this.operator = operator;
   }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java?rev=1366198&r1=1366197&r2=1366198&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
Thu Jul 26 20:53:17 2012
@@ -54,6 +54,27 @@ public class TestFilterList {
   static byte[] GOOD_BYTES = Bytes.toBytes("abc");
   static byte[] BAD_BYTES = Bytes.toBytes("def");
 
+
+  @Test
+  public void testAddFilter() throws Exception {
+    Filter filter1 = new RowFilter();
+    Filter filter2 = new RowFilter();
+
+    FilterList filterList = new FilterList(filter1, filter2);
+    filterList.addFilter(new RowFilter());
+
+    filterList = new FilterList(Arrays.asList(filter1, filter2));
+    filterList.addFilter(new RowFilter());
+
+    filterList = new FilterList(Operator.MUST_PASS_ALL, filter1, filter2);
+    filterList.addFilter(new RowFilter());
+
+    filterList = new FilterList(Operator.MUST_PASS_ALL, Arrays.asList(filter1, filter2));
+    filterList.addFilter(new RowFilter());
+
+  }
+
+
   /**
    * Test "must pass one"
    * @throws Exception



Mime
View raw message