HBASE-16310 Revisit the logic of filterRowKey for Filters (Ram)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2d203e60 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2d203e60 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2d203e60 Branch: refs/heads/hbase-12439 Commit: 2d203e6053defb52cd3629d49ae6d54460c658dd Parents: 46defe8 Author: Ramkrishna <ramkrishna.s.vasude...@intel.com> Authored: Wed Aug 10 13:54:25 2016 +0530 Committer: Ramkrishna <ramkrishna.s.vasude...@intel.com> Committed: Wed Aug 10 13:54:25 2016 +0530 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java | 1 + .../src/main/java/org/apache/hadoop/hbase/filter/Filter.java | 2 ++ .../src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java | 2 ++ .../main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java | 2 ++ .../java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java | 1 + .../java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java | 1 + .../src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java | 1 + .../src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java | 1 + .../main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java | 1 + 9 files changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java index fd65130..c747b00 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java @@ -55,6 +55,7 @@ public class ColumnCountGetFilter extends FilterBase { @Override public boolean filterRowKey(Cell cell) throws IOException { // Impl in FilterBase might do unnecessary copy for Off heap backed Cells. + if (filterAllRemaining()) return true; return false; } http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java index 22ca8ac..59aa855 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java @@ -87,6 +87,8 @@ public abstract class Filter { /** * Filters a row based on the row key. If this returns true, the entire row will be excluded. If * false, each KeyValue in the row will be passed to {@link #filterKeyValue(Cell)} below. + * If {@link #filterAllRemaining()} returns true, then {@link #filterRowKey(Cell)} should + * also return true. * * Concrete implementers can signal a failure condition in their code by throwing an * {@link IOException}. http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java index fc00d02..e59f324 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java @@ -58,11 +58,13 @@ public abstract class FilterBase extends Filter { @Override @Deprecated public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException { + if (filterAllRemaining()) return true; return false; } @Override public boolean filterRowKey(Cell cell) throws IOException { + if (filterAllRemaining()) return true; return filterRowKey(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); } http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java index 4d7a18a..617cd7a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java @@ -103,11 +103,13 @@ final public class FilterWrapper extends Filter { @Override public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException { // No call to this. + if (filterAllRemaining()) return true; return this.filter.filterRowKey(buffer, offset, length); } @Override public boolean filterRowKey(Cell cell) throws IOException { + if (filterAllRemaining()) return true; return this.filter.filterRowKey(cell); } http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java index 1096f5e..5dcb50d 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java @@ -61,6 +61,7 @@ public class InclusiveStopFilter extends FilterBase { public boolean filterRowKey(Cell firstRowCell) { // if stopRowKey is <= buffer, then true, filter row. + if (filterAllRemaining()) return true; int cmp = CellComparator.COMPARATOR.compareRows(firstRowCell, stopRowKey, 0, stopRowKey.length); done = reversed ? cmp < 0 : cmp > 0; return done; http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java index 5f9c833..3f26586 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java @@ -85,6 +85,7 @@ public class MultiRowRangeFilter extends FilterBase { @Override public boolean filterRowKey(Cell firstRowCell) { + if (filterAllRemaining()) return true; // If it is the first time of running, calculate the current range index for // the row key. If index is out of bound which happens when the start row // user sets is after the largest stop row of the ranges, stop the scan. http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java index adc9c54..f12fac8 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java @@ -63,6 +63,7 @@ public class PageFilter extends FilterBase { @Override public boolean filterRowKey(Cell cell) throws IOException { // Impl in FilterBase might do unnecessary copy for Off heap backed Cells. + if (filterAllRemaining()) return true; return false; } http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java index d09ea2c..e7b91e1 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java @@ -55,6 +55,7 @@ public class PrefixFilter extends FilterBase { public boolean filterRowKey(Cell firstRowCell) { if (firstRowCell == null || this.prefix == null) return true; + if (filterAllRemaining()) return true; int length = firstRowCell.getRowLength(); if (length < prefix.length) return true; // if they are equal, return false => pass row http://git-wip-us.apache.org/repos/asf/hbase/blob/2d203e60/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java index e75ca49..93b4a00 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/WhileMatchFilter.java @@ -74,6 +74,7 @@ public class WhileMatchFilter extends FilterBase { @Override public boolean filterRowKey(Cell cell) throws IOException { + if (filterAllRemaining()) return true; boolean value = filter.filterRowKey(cell); changeFAR(value); return value;