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

This commit is contained in:
tedyu 2015-08-11 09:40:13 -07:00
parent d49b1f60f4
commit a2dbe31b26
2 changed files with 26 additions and 0 deletions

View File

@ -237,6 +237,9 @@ public class MultiRowRangeFilter extends FilterBase {
if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) { if (insertionPosition == 0 && !rangeList.get(insertionPosition).contains(rowKey)) {
return ROW_BEFORE_FIRST_RANGE; return ROW_BEFORE_FIRST_RANGE;
} }
if (!initialized) {
initialized = true;
}
return insertionPosition; return insertionPosition;
} }
// the row key equals one of the start keys, and the the range exclude the start key // the row key equals one of the start keys, and the the range exclude the start key

View File

@ -71,6 +71,29 @@ public class TestMultiRowRangeFilter {
TEST_UTIL.shutdownMiniCluster(); 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 @Test
public void testOutOfOrderScannerNextException() throws Exception { public void testOutOfOrderScannerNextException() throws Exception {
MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList( MultiRowRangeFilter filter = new MultiRowRangeFilter(Arrays.asList(