HBASE-14206 MultiRowRangeFilter returns records whose rowKeys are out of allowed ranges (Anton Nazaruk)

This commit is contained in:
tedyu 2015-08-11 10:01:55 -07:00
parent c07eb21e4b
commit 90b8cc89bd
2 changed files with 21 additions and 0 deletions

View File

@ -233,6 +233,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

View File

@ -69,6 +69,24 @@ 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(badKey, 0, 1);
assertEquals(Filter.ReturnCode.SEEK_NEXT_USING_HINT, filter.filterKeyValue(null));
}
@Test
public void testOutOfOrderScannerNextException() throws Exception {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(