hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [4/6] hbase git commit: HBASE-15410 Utilize the max seek value when all Filters in MUST_PASS_ALL FilterList return SEEK_NEXT_USING_HINT
Date Tue, 10 Oct 2017 04:17:52 GMT
HBASE-15410 Utilize the max seek value when all Filters in MUST_PASS_ALL FilterList return
SEEK_NEXT_USING_HINT


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5119d607
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5119d607
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5119d607

Branch: refs/heads/HBASE-18410
Commit: 5119d607613d531c395a5b9059951e208649c85f
Parents: c3ac4e4
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Sep 7 04:07:09 2017 -0700
Committer: Sean Busbey <busbey@apache.org>
Committed: Mon Oct 9 23:03:22 2017 -0500

----------------------------------------------------------------------
 .../apache/hadoop/hbase/filter/FilterList.java  | 31 ++++++++++++++++----
 .../hadoop/hbase/filter/TestFilterList.java     |  6 ++--
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5119d607/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
index 7969db7..cd51648 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
@@ -22,7 +22,9 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellComparator;
@@ -65,7 +67,7 @@ final public class FilterList extends FilterBase {
   private static final int MAX_LOG_FILTERS = 5;
   private Operator operator = Operator.MUST_PASS_ALL;
   private final List<Filter> filters;
-  private Filter seekHintFilter = null;
+  private Set<Filter> seekHintFilter = new HashSet<>();
 
   /**
    * Save previous return code and previous cell for every filter in filter list. For MUST_PASS_ONE,
@@ -234,7 +236,7 @@ final public class FilterList extends FilterBase {
         prevCellList.set(i, null);
       }
     }
-    seekHintFilter = null;
+    seekHintFilter.clear();
   }
 
   @Override
@@ -358,6 +360,7 @@ final public class FilterList extends FilterBase {
       return ReturnCode.INCLUDE;
     }
     this.referenceCell = c;
+    seekHintFilter.clear();
 
     // Accumulates successive transformation of every filter that includes the Cell:
     Cell transformed = c;
@@ -389,10 +392,12 @@ final public class FilterList extends FilterBase {
           transformed = filter.transformCell(transformed);
           continue;
         case SEEK_NEXT_USING_HINT:
-          seekHintFilter = filter;
-          return code;
+          seekHintFilter.add(filter);
+          continue;
         default:
-          return code;
+          if (seekHintFilter.isEmpty()) {
+            return code;
+          }
         }
       } else if (operator == Operator.MUST_PASS_ONE) {
         Cell prevCell = this.prevCellList.get(i);
@@ -442,6 +447,10 @@ final public class FilterList extends FilterBase {
       }
     }
 
+    if (!seekHintFilter.isEmpty()) {
+      return ReturnCode.SEEK_NEXT_USING_HINT;
+    }
+
     // Save the transformed Cell for transform():
     this.transformedCell = transformed;
 
@@ -565,7 +574,17 @@ final public class FilterList extends FilterBase {
     }
     Cell keyHint = null;
     if (operator == Operator.MUST_PASS_ALL) {
-      if (seekHintFilter != null) keyHint = seekHintFilter.getNextCellHint(currentCell);
+      for (Filter filter : seekHintFilter) {
+        if (filter.filterAllRemaining()) continue;
+        Cell curKeyHint = filter.getNextCellHint(currentCell);
+        if (keyHint == null) {
+          keyHint = curKeyHint;
+          continue;
+        }
+        if (CellComparator.COMPARATOR.compare(keyHint, curKeyHint) < 0) {
+          keyHint = curKeyHint;
+        }
+      }
       return keyHint;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/5119d607/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
index 90f95a5..f20a9ba 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
@@ -502,7 +502,7 @@ public class TestFilterList {
     FilterList filterList = new FilterList(Operator.MUST_PASS_ONE,
         Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
     assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
-        minKeyValue));
+      minKeyValue));
 
     // Should have no hint if any filter has no hint
     filterList = new FilterList(Operator.MUST_PASS_ONE,
@@ -526,7 +526,7 @@ public class TestFilterList {
         Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
     filterList.filterKeyValue(null);
     assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
-        minKeyValue));
+        maxKeyValue));
 
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterMaxHint, filterMinHint } ));
@@ -540,7 +540,7 @@ public class TestFilterList {
             new Filter [] { filterNoHint, filterMinHint, filterMaxHint } ));
     filterList.filterKeyValue(null);
     assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
-        minKeyValue));
+        maxKeyValue));
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
     filterList.filterKeyValue(null);


Mime
View raw message