HBASE-14206 MultiRowRangeFilter returns records whose rowKeys are out of allowed ranges (Anton Nazaruk)
This commit is contained in:
parent
d49b1f60f4
commit
a2dbe31b26
|
@ -237,6 +237,9 @@ public class MultiRowRangeFilter extends FilterBase {
|
|||
if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) {
|
||||
return ROW_BEFORE_FIRST_RANGE;
|
||||
}
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
}
|
||||
return insertionPosition;
|
||||
}
|
||||
// the row key equals one of the start keys, and the the range exclude the start key
|
||||
|
|
|
@ -71,6 +71,29 @@ public class TestMultiRowRangeFilter {
|
|||
TEST_UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRanges() throws IOException {
|
||||
byte[] key1Start = new byte[] {-3};
|
||||
byte[] key1End = new byte[] {-2};
|
||||
|
||||
byte[] key2Start = new byte[] {5};
|
||||
byte[] key2End = new byte[] {6};
|
||||
|
||||
byte[] badKey = new byte[] {-10};
|
||||
|
||||
MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
|
||||
new MultiRowRangeFilter.RowRange(key1Start, true, key1End, false),
|
||||
new MultiRowRangeFilter.RowRange(key2Start, true, key2End, false)
|
||||
));
|
||||
filter.filterRowKey(KeyValueUtil.createFirstOnRow(badKey));
|
||||
/*
|
||||
* FAILS -- includes BAD key!
|
||||
* Expected :SEEK_NEXT_USING_HINT
|
||||
* Actual :INCLUDE
|
||||
* */
|
||||
assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutOfOrderScannerNextException() throws Exception {
|
||||
MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(
|
||||
|
|
Loading…
Reference in New Issue