You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by bu...@apache.org on 2017/09/11 07:42:37 UTC
[10/50] [abbrv] hbase git commit: HBASE-15410 Utilize the max seek
value when all Filters in MUST_PASS_ALL FilterList return
SEEK_NEXT_USING_HINT
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/df34300c
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/df34300c
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/df34300c
Branch: refs/heads/HBASE-18467
Commit: df34300cd3f89c1efdea43b0b2ecb64c317e1a34
Parents: 3a9dc8f
Author: tedyu <yu...@gmail.com>
Authored: Thu Sep 7 04:07:09 2017 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Thu Sep 7 04:07:09 2017 -0700
----------------------------------------------------------------------
.../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/df34300c/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 7433cca..0ce2ee6 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/df34300c/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 bcb6617..f7c1b20 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
@@ -501,7 +501,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,
@@ -525,7 +525,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 } ));
@@ -539,7 +539,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);