HBASE-14397 PrefixFilter doesn't filter all remaining rows if the prefix is longer than rowkey being compared (Jianwei Cui)
This commit is contained in:
parent
be96bb6adf
commit
6c90507314
@ -38,9 +38,11 @@ import java.util.ArrayList;
|
|||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Stable
|
@InterfaceStability.Stable
|
||||||
public class PrefixFilter extends FilterBase {
|
public class PrefixFilter extends FilterBase {
|
||||||
|
public static final int MAX_SKIPPED_COMPARE_ROW_NUM = 100;
|
||||||
protected byte [] prefix = null;
|
protected byte [] prefix = null;
|
||||||
protected boolean passedPrefix = false;
|
protected boolean passedPrefix = false;
|
||||||
protected boolean filterRow = true;
|
protected boolean filterRow = true;
|
||||||
|
protected int skippedCompareRows = 0;
|
||||||
|
|
||||||
public PrefixFilter(final byte [] prefix) {
|
public PrefixFilter(final byte [] prefix) {
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
@ -53,8 +55,12 @@ public class PrefixFilter extends FilterBase {
|
|||||||
public boolean filterRowKey(byte[] buffer, int offset, int length) {
|
public boolean filterRowKey(byte[] buffer, int offset, int length) {
|
||||||
if (buffer == null || this.prefix == null)
|
if (buffer == null || this.prefix == null)
|
||||||
return true;
|
return true;
|
||||||
if (length < prefix.length)
|
if (length < prefix.length && skippedCompareRows < MAX_SKIPPED_COMPARE_ROW_NUM) {
|
||||||
|
++skippedCompareRows;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
skippedCompareRows = 0;
|
||||||
|
|
||||||
// if they are equal, return false => pass row
|
// if they are equal, return false => pass row
|
||||||
// else return true, filter row
|
// else return true, filter row
|
||||||
// if we are passed the prefix, set flag
|
// if we are passed the prefix, set flag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user