HBASE-15410 Utilize the max seek value when all Filters in MUST_PASS_ALL FilterList return SEEK_NEXT_USING_HINT
This commit is contained in:
parent
7592cb8d34
commit
743f3ae221
|
@ -22,7 +22,9 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellComparator;
|
||||
|
@ -65,7 +67,7 @@ final public class FilterList extends FilterBase {
|
|||
private static final int MAX_LOG_FILTERS = 5;
|
||||
private Operator operator = Operator.MUST_PASS_ALL;
|
||||
private final List<Filter> filters;
|
||||
private Filter seekHintFilter = null;
|
||||
private Set<Filter> seekHintFilter = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Save previous return code and previous cell for every filter in filter list. For MUST_PASS_ONE,
|
||||
|
@ -234,7 +236,7 @@ final public class FilterList extends FilterBase {
|
|||
prevCellList.set(i, null);
|
||||
}
|
||||
}
|
||||
seekHintFilter = null;
|
||||
seekHintFilter.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -358,6 +360,7 @@ final public class FilterList extends FilterBase {
|
|||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
this.referenceCell = c;
|
||||
seekHintFilter.clear();
|
||||
|
||||
// Accumulates successive transformation of every filter that includes the Cell:
|
||||
Cell transformed = c;
|
||||
|
@ -389,11 +392,13 @@ final public class FilterList extends FilterBase {
|
|||
transformed = filter.transformCell(transformed);
|
||||
continue;
|
||||
case SEEK_NEXT_USING_HINT:
|
||||
seekHintFilter = filter;
|
||||
return code;
|
||||
seekHintFilter.add(filter);
|
||||
continue;
|
||||
default:
|
||||
if (seekHintFilter.isEmpty()) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
} else if (operator == Operator.MUST_PASS_ONE) {
|
||||
Cell prevCell = this.prevCellList.get(i);
|
||||
if (filter.filterAllRemaining() || !shouldPassCurrentCellToFilter(prevCell, c, i)) {
|
||||
|
@ -442,6 +447,10 @@ final public class FilterList extends FilterBase {
|
|||
}
|
||||
}
|
||||
|
||||
if (!seekHintFilter.isEmpty()) {
|
||||
return ReturnCode.SEEK_NEXT_USING_HINT;
|
||||
}
|
||||
|
||||
// Save the transformed Cell for transform():
|
||||
this.transformedCell = transformed;
|
||||
|
||||
|
@ -565,7 +574,17 @@ final public class FilterList extends FilterBase {
|
|||
}
|
||||
Cell keyHint = null;
|
||||
if (operator == Operator.MUST_PASS_ALL) {
|
||||
if (seekHintFilter != null) keyHint = seekHintFilter.getNextCellHint(currentCell);
|
||||
for (Filter filter : seekHintFilter) {
|
||||
if (filter.filterAllRemaining()) continue;
|
||||
Cell curKeyHint = filter.getNextCellHint(currentCell);
|
||||
if (keyHint == null) {
|
||||
keyHint = curKeyHint;
|
||||
continue;
|
||||
}
|
||||
if (CellComparator.COMPARATOR.compare(keyHint, curKeyHint) < 0) {
|
||||
keyHint = curKeyHint;
|
||||
}
|
||||
}
|
||||
return keyHint;
|
||||
}
|
||||
|
||||
|
|
|
@ -525,7 +525,7 @@ public class TestFilterList {
|
|||
Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
|
||||
filterList.filterKeyValue(null);
|
||||
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
||||
minKeyValue));
|
||||
maxKeyValue));
|
||||
|
||||
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
||||
Arrays.asList(new Filter [] { filterMaxHint, filterMinHint } ));
|
||||
|
@ -539,7 +539,7 @@ public class TestFilterList {
|
|||
new Filter [] { filterNoHint, filterMinHint, filterMaxHint } ));
|
||||
filterList.filterKeyValue(null);
|
||||
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
||||
minKeyValue));
|
||||
maxKeyValue));
|
||||
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
||||
Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
|
||||
filterList.filterKeyValue(null);
|
||||
|
|
Loading…
Reference in New Issue