HBASE-13491 Issue in FuzzyRowFilter#getNextForFuzzyRule (Anoop Sam John)
This commit is contained in:
parent
66e55ff388
commit
92e922e11d
|
@ -337,7 +337,8 @@ public class FuzzyRowFilter extends FilterBase {
|
||||||
* @return greater byte array than given (row) which satisfies the fuzzy rule if it exists,
|
* @return greater byte array than given (row) which satisfies the fuzzy rule if it exists,
|
||||||
* null otherwise
|
* null otherwise
|
||||||
*/
|
*/
|
||||||
private static byte[] getNextForFuzzyRule(boolean reverse, byte[] row, int offset, int length,
|
@VisibleForTesting
|
||||||
|
static byte[] getNextForFuzzyRule(boolean reverse, byte[] row, int offset, int length,
|
||||||
byte[] fuzzyKeyBytes, byte[] fuzzyKeyMeta) {
|
byte[] fuzzyKeyBytes, byte[] fuzzyKeyMeta) {
|
||||||
// To find out the next "smallest" byte array that satisfies fuzzy rule and "greater" than
|
// To find out the next "smallest" byte array that satisfies fuzzy rule and "greater" than
|
||||||
// the given one we do the following:
|
// the given one we do the following:
|
||||||
|
@ -362,7 +363,7 @@ public class FuzzyRowFilter extends FilterBase {
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
if (i >= fuzzyKeyMeta.length || fuzzyKeyMeta[i] == 1) {
|
if (i >= fuzzyKeyMeta.length || fuzzyKeyMeta[i] == 1) {
|
||||||
result[i] = row[offset + i];
|
result[i] = row[offset + i];
|
||||||
if (!order.isMax(row[i])) {
|
if (!order.isMax(row[offset + i])) {
|
||||||
// this is "non-fixed" position and is not at max value, hence we can increase it
|
// this is "non-fixed" position and is not at max value, hence we can increase it
|
||||||
toInc = i;
|
toInc = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.filter;
|
package org.apache.hadoop.hbase.filter;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
|
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||||
import org.apache.hadoop.hbase.testclassification.FilterTests;
|
import org.apache.hadoop.hbase.testclassification.FilterTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -401,7 +403,9 @@ public class TestFuzzyRowFilter {
|
||||||
|
|
||||||
private static void assertNext(boolean reverse, byte[] fuzzyRow, byte[] mask, byte[] current,
|
private static void assertNext(boolean reverse, byte[] fuzzyRow, byte[] mask, byte[] current,
|
||||||
byte[] expected) {
|
byte[] expected) {
|
||||||
byte[] nextForFuzzyRule = FuzzyRowFilter.getNextForFuzzyRule(reverse, current, fuzzyRow, mask);
|
KeyValue kv = KeyValueUtil.createFirstOnRow(current);
|
||||||
|
byte[] nextForFuzzyRule = FuzzyRowFilter.getNextForFuzzyRule(reverse, kv.getRowArray(),
|
||||||
|
kv.getRowOffset(), kv.getRowLength(), fuzzyRow, mask);
|
||||||
Assert.assertEquals(Bytes.toStringBinary(expected), Bytes.toStringBinary(nextForFuzzyRule));
|
Assert.assertEquals(Bytes.toStringBinary(expected), Bytes.toStringBinary(nextForFuzzyRule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue