HBASE-16310 Revisit the logic of filterRowKey for Filters (Ram)
This commit is contained in:
parent
46defe8e31
commit
2d203e6053
|
@ -55,6 +55,7 @@ public class ColumnCountGetFilter extends FilterBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell cell) throws IOException {
|
public boolean filterRowKey(Cell cell) throws IOException {
|
||||||
// Impl in FilterBase might do unnecessary copy for Off heap backed Cells.
|
// Impl in FilterBase might do unnecessary copy for Off heap backed Cells.
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* 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.
|
* 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
|
* Concrete implementers can signal a failure condition in their code by throwing an
|
||||||
* {@link IOException}.
|
* {@link IOException}.
|
||||||
|
|
|
@ -58,11 +58,13 @@ public abstract class FilterBase extends Filter {
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException {
|
public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException {
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell cell) throws IOException {
|
public boolean filterRowKey(Cell cell) throws IOException {
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return filterRowKey(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
|
return filterRowKey(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,11 +103,13 @@ final public class FilterWrapper extends Filter {
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException {
|
public boolean filterRowKey(byte[] buffer, int offset, int length) throws IOException {
|
||||||
// No call to this.
|
// No call to this.
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return this.filter.filterRowKey(buffer, offset, length);
|
return this.filter.filterRowKey(buffer, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell cell) throws IOException {
|
public boolean filterRowKey(Cell cell) throws IOException {
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return this.filter.filterRowKey(cell);
|
return this.filter.filterRowKey(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class InclusiveStopFilter extends FilterBase {
|
||||||
|
|
||||||
public boolean filterRowKey(Cell firstRowCell) {
|
public boolean filterRowKey(Cell firstRowCell) {
|
||||||
// if stopRowKey is <= buffer, then true, filter row.
|
// if stopRowKey is <= buffer, then true, filter row.
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
int cmp = CellComparator.COMPARATOR.compareRows(firstRowCell, stopRowKey, 0, stopRowKey.length);
|
int cmp = CellComparator.COMPARATOR.compareRows(firstRowCell, stopRowKey, 0, stopRowKey.length);
|
||||||
done = reversed ? cmp < 0 : cmp > 0;
|
done = reversed ? cmp < 0 : cmp > 0;
|
||||||
return done;
|
return done;
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class MultiRowRangeFilter extends FilterBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell firstRowCell) {
|
public boolean filterRowKey(Cell firstRowCell) {
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
// If it is the first time of running, calculate the current range index for
|
// 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
|
// 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.
|
// user sets is after the largest stop row of the ranges, stop the scan.
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class PageFilter extends FilterBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell cell) throws IOException {
|
public boolean filterRowKey(Cell cell) throws IOException {
|
||||||
// Impl in FilterBase might do unnecessary copy for Off heap backed Cells.
|
// Impl in FilterBase might do unnecessary copy for Off heap backed Cells.
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class PrefixFilter extends FilterBase {
|
||||||
public boolean filterRowKey(Cell firstRowCell) {
|
public boolean filterRowKey(Cell firstRowCell) {
|
||||||
if (firstRowCell == null || this.prefix == null)
|
if (firstRowCell == null || this.prefix == null)
|
||||||
return true;
|
return true;
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
int length = firstRowCell.getRowLength();
|
int length = firstRowCell.getRowLength();
|
||||||
if (length < prefix.length) return true;
|
if (length < prefix.length) return true;
|
||||||
// if they are equal, return false => pass row
|
// if they are equal, return false => pass row
|
||||||
|
|
|
@ -74,6 +74,7 @@ public class WhileMatchFilter extends FilterBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean filterRowKey(Cell cell) throws IOException {
|
public boolean filterRowKey(Cell cell) throws IOException {
|
||||||
|
if (filterAllRemaining()) return true;
|
||||||
boolean value = filter.filterRowKey(cell);
|
boolean value = filter.filterRowKey(cell);
|
||||||
changeFAR(value);
|
changeFAR(value);
|
||||||
return value;
|
return value;
|
||||||
|
|
Loading…
Reference in New Issue