Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Abandoned
-
0.90.0, 0.94.7
-
None
-
None
Description
When performing a Get operation where a both a column is specified and a ValueFilter, the ValueFilter is evaluated before making the column match as is indicated in the javadoc of Get.setFilter() : "
{@link Filter#filterKeyValue(KeyValue)}is called AFTER all tests for ttl, column match, deletes and max versions have been run. "
The is shown in the little test below, which uses a TestComparator extending a WritableByteArrayComparable.
public void testFilter() throws Exception {
byte[] cf = Bytes.toBytes("cf");
byte[] row = Bytes.toBytes("row");
byte[] col1 = Bytes.toBytes("col1");
byte[] col2 = Bytes.toBytes("col2");
Put put = new Put(row);
put.add(cf, col1, new byte[]
);
put.add(cf, col2, new byte[]
);
table.put(put);
Get get = new Get(row);
get.addColumn(cf, col2); // We only want to retrieve col2
TestComparator testComparator = new TestComparator();
Filter filter = new ValueFilter(CompareOp.EQUAL, testComparator);
get.setFilter(filter);
Result result = table.get(get);
}
public class TestComparator extends WritableByteArrayComparable {
/**
- Nullary constructor, for Writable
*/
public TestComparator() { super(); }
@Override
public int compareTo(byte[] theirValue) {
if (theirValue[0] == (byte)1)
if (theirValue[0] == (byte)2)
{ return 0; } else return 1;
}
}
When only one column should be retrieved, this can be worked around by using a SingleColumnValueFilter instead of the ValueFilter.
Attachments
Attachments
Issue Links
- relates to
-
HBASE-8930 Filter evaluates KVs outside requested columns
- Closed
-
HBASE-16225 Refactor ScanQueryMatcher
- Resolved