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
a4bc3c6db7
commit
77bfe05503
|
@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.filter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ final public class FilterList extends FilterBase {
|
||||||
private static final int MAX_LOG_FILTERS = 5;
|
private static final int MAX_LOG_FILTERS = 5;
|
||||||
private Operator operator = Operator.MUST_PASS_ALL;
|
private Operator operator = Operator.MUST_PASS_ALL;
|
||||||
private final List<Filter> filters;
|
private final List<Filter> filters;
|
||||||
private Filter seekHintFilter = null;
|
private Collection<Filter> seekHintFilters = new ArrayList<Filter>();
|
||||||
|
|
||||||
/** Reference Cell used by {@link #transformCell(Cell)} for validation purpose. */
|
/** Reference Cell used by {@link #transformCell(Cell)} for validation purpose. */
|
||||||
private Cell referenceCell = null;
|
private Cell referenceCell = null;
|
||||||
|
@ -201,7 +202,7 @@ final public class FilterList extends FilterBase {
|
||||||
for (int i = 0; i < listize; i++) {
|
for (int i = 0; i < listize; i++) {
|
||||||
filters.get(i).reset();
|
filters.get(i).reset();
|
||||||
}
|
}
|
||||||
seekHintFilter = null;
|
seekHintFilters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -290,6 +291,7 @@ final public class FilterList extends FilterBase {
|
||||||
return ReturnCode.INCLUDE;
|
return ReturnCode.INCLUDE;
|
||||||
}
|
}
|
||||||
this.referenceCell = c;
|
this.referenceCell = c;
|
||||||
|
seekHintFilters.clear();
|
||||||
|
|
||||||
// Accumulates successive transformation of every filter that includes the Cell:
|
// Accumulates successive transformation of every filter that includes the Cell:
|
||||||
Cell transformed = c;
|
Cell transformed = c;
|
||||||
|
@ -321,11 +323,13 @@ final public class FilterList extends FilterBase {
|
||||||
transformed = filter.transformCell(transformed);
|
transformed = filter.transformCell(transformed);
|
||||||
continue;
|
continue;
|
||||||
case SEEK_NEXT_USING_HINT:
|
case SEEK_NEXT_USING_HINT:
|
||||||
seekHintFilter = filter;
|
seekHintFilters.add(filter);
|
||||||
return code;
|
continue;
|
||||||
default:
|
default:
|
||||||
|
if (seekHintFilters.isEmpty()) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (operator == Operator.MUST_PASS_ONE) {
|
} else if (operator == Operator.MUST_PASS_ONE) {
|
||||||
if (filter.filterAllRemaining()) {
|
if (filter.filterAllRemaining()) {
|
||||||
seenNonHintReturnCode = true;
|
seenNonHintReturnCode = true;
|
||||||
|
@ -362,6 +366,10 @@ final public class FilterList extends FilterBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!seekHintFilters.isEmpty()) {
|
||||||
|
return ReturnCode.SEEK_NEXT_USING_HINT;
|
||||||
|
}
|
||||||
|
|
||||||
// Save the transformed Cell for transform():
|
// Save the transformed Cell for transform():
|
||||||
this.transformedCell = transformed;
|
this.transformedCell = transformed;
|
||||||
|
|
||||||
|
@ -485,7 +493,17 @@ final public class FilterList extends FilterBase {
|
||||||
}
|
}
|
||||||
Cell keyHint = null;
|
Cell keyHint = null;
|
||||||
if (operator == Operator.MUST_PASS_ALL) {
|
if (operator == Operator.MUST_PASS_ALL) {
|
||||||
keyHint = seekHintFilter.getNextCellHint(currentCell);
|
for (Filter filter : seekHintFilters) {
|
||||||
|
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;
|
return keyHint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ public class TestFilterList {
|
||||||
Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
|
Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
|
||||||
filterList.filterKeyValue(null);
|
filterList.filterKeyValue(null);
|
||||||
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
||||||
minKeyValue));
|
maxKeyValue));
|
||||||
|
|
||||||
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
||||||
Arrays.asList(new Filter [] { filterMaxHint, filterMinHint } ));
|
Arrays.asList(new Filter [] { filterMaxHint, filterMinHint } ));
|
||||||
|
@ -539,7 +539,7 @@ public class TestFilterList {
|
||||||
new Filter [] { filterNoHint, filterMinHint, filterMaxHint } ));
|
new Filter [] { filterNoHint, filterMinHint, filterMaxHint } ));
|
||||||
filterList.filterKeyValue(null);
|
filterList.filterKeyValue(null);
|
||||||
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
assertEquals(0, CellComparator.COMPARATOR.compare(filterList.getNextCellHint(null),
|
||||||
minKeyValue));
|
maxKeyValue));
|
||||||
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
filterList = new FilterList(Operator.MUST_PASS_ALL,
|
||||||
Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
|
Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
|
||||||
filterList.filterKeyValue(null);
|
filterList.filterKeyValue(null);
|
||||||
|
|
Loading…
Reference in New Issue