HBASE-17678 FilterList with MUST_PASS_ONE lead to redundancy cells returned - 
addendum

Signed-off-by: tedyu <yuzhih...@gmail.com>


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

Branch: refs/heads/HBASE-18410
Commit: 3f5f2a544691ba156705c87e3fd71c02ca1e7f5c
Parents: 49a877d
Author: huzheng <open...@gmail.com>
Authored: Wed Jun 7 14:49:29 2017 +0800
Committer: zhangduo <zhang...@apache.org>
Committed: Tue Oct 24 11:30:34 2017 +0800

----------------------------------------------------------------------
 .../java/org/apache/hadoop/hbase/filter/FilterList.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3f5f2a54/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 3493082..83db1f2 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
@@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellComparatorImpl;
 import org.apache.hadoop.hbase.CellUtil;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos;
@@ -145,7 +146,7 @@ final public class FilterList extends FilterBase {
 
   public void initPrevListForMustPassOne(int size) {
     if (operator == Operator.MUST_PASS_ONE) {
-      if (this.prevCellList == null) {
+      if (this.prevFilterRCList == null) {
         prevFilterRCList = new ArrayList<>(Collections.nCopies(size, null));
       }
       if (this.prevCellList == null) {
@@ -407,7 +408,14 @@ final public class FilterList extends FilterBase {
         ReturnCode localRC = filter.filterKeyValue(c);
         // Update previous cell and return code we encountered.
         prevFilterRCList.set(i, localRC);
-        prevCellList.set(i, c);
+        if (c == null || localRC == ReturnCode.INCLUDE || localRC == 
ReturnCode.SKIP) {
+          // If previous return code is INCLUDE or SKIP, we should always pass 
the next cell to the
+          // corresponding sub-filter(need not test 
shouldPassCurrentCellToFilter() method), So we
+          // need not save current cell to prevCellList for saving heap memory.
+          prevCellList.set(i, null);
+        } else {
+          prevCellList.set(i, KeyValueUtil.toNewKeyCell(c));
+        }
 
         if (localRC != ReturnCode.SEEK_NEXT_USING_HINT) {
           seenNonHintReturnCode = true;

Reply via email to