[
https://issues.apache.org/jira/browse/HBASE-6429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421303#comment-13421303
]
Jie Huang commented on HBASE-6429:
----------------------------------
Here is another example using existing filter.
{code}
private static void prepareData() {
try {
HTable table = new HTable(TestFilter.conf, name);
assertTrue("Fail to create the table", admin.tableExists(name));
List<Put> puts = new ArrayList<Put>();
// row1 => <f1:c1 , 1_c1, ts=1> , <f1:c2 , 1_c2,ts=2>, <f1:c3 ,
1_c3,ts=3>, <f1:c4 ,
// 1_c4,ts=4>, <f1:c5 , 1_c5,ts=5>
// row2 => <f1:c1 , 2_c1, ts=2> , <f1:c2 , 2_c2, ts=2>, <f1:c3 , 2_c3,
ts=2>, <f1:c4 ,
// 2_c4, ts=2>, <f1:c5 , 2_c5, ts=2>
// row3 => <f1:c1 , 3_c1, ts=3> , <f1:c2 , 3_c2, ts=3>, <f1:c3 ,
3_c3, ts=3>, <f1:c4 ,
// 3_c4, ts=3>, <f1:c5 , 3_c5, ts=3>
for (int i = 1; i < 4; i++) {
Put put = new Put(Bytes.toBytes("row" + i));
for (int j = 1; j < 6; j++) {
long timestamp = j;
if(i!=1) timestamp = i;
put.add(Bytes.toBytes("f1"),
Bytes.toBytes("c" + j),
timestamp,
Bytes.toBytes(i + "_c" + j));
}
puts.add(put);
}
table.put(puts);
table.close();
} catch (IOException e) {
e.printStackTrace();
assertNull("Exception found while putting data into table", e);
}
}
public testFilter() {
int kv_number = 0;
int row_number = 0;
try {
Scan scan = new Scan();
List<Filter> fs = new ArrayList<Filter>();
DependentColumnFilter f1 = new DependentColumnFilter(Bytes.toBytes("f1"),
Bytes.toBytes("c5"), true, CompareFilter.CompareOp.EQUAL,
new SubstringComparator("c5"));
PageFilter f2 = new PageFilter(2);
fs.add(f1);
fs.add(f2);
FilterList filter = new FilterList(fs);
scan.setFilter(filter);
HTable table = new HTable(conf, name);
ResultScanner scanner = table.getScanner(scan);
// row2 (c1-c4) and row3(c1-c4) are returned
for (Result result : scanner) {
row_number++;
for (KeyValue kv : result.list()) {
LOG.debug(kv_number + ". kv: " + kv);
kv_number++;
assertEquals("Returned row is not correct", new String(kv.getRow()),
"row" + (row_number+1));
}
}
scanner.close();
table.close();
} catch (Exception e) {
assertNull("Exception happens in scan", e);
}
LOG.debug("check the fetched kv number");
assertEquals("We should get 8 results returned.", 8, kv_number);
assertEquals("We should get 2 rows returned", 2, row_number);
}
{code}
> Filter with filterRow() returning true is incompatible with scan with limit
> ---------------------------------------------------------------------------
>
> Key: HBASE-6429
> URL: https://issues.apache.org/jira/browse/HBASE-6429
> Project: HBase
> Issue Type: Bug
> Components: filters
> Affects Versions: 0.96.0
> Reporter: Jason Dai
> Attachments: hbase-6429-trunk.patch, hbase-6429_0_94_0.patch
>
>
> Currently if we scan with bot limit and a Filter with
> filterRow(List<KeyValue>) implemented, an IncompatibleFilterException will
> be thrown. The same exception should also be thrown if the filer has its
> filterRow() implemented.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira