HBASE-16310 Revisit the logic of filterRowKey for Filters (Ram)

This commit is contained in:
Ramkrishna 2016-08-10 13:54:25 +05:30
parent 46defe8e31
commit 2d203e6053
9 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -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}.

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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.

View File

@ -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;
}

View File

@ -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

View File

@ -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;