[ 
https://issues.apache.org/jira/browse/HBASE-26967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615038#comment-17615038
 ] 

chaijunjie commented on HBASE-26967:
------------------------------------

[~zhangduo] hi, I think there are an example to support add a filterRow method.

eg1. we has 3 filters in filterList:

there is one row

f1–has filterRow–>{*}return true{*}

f2–has filterRow–>{*}return true{*}

f3–not has filterRow–not consider

*When we do not consider the filterRow result of f3,* the row will be *dropped* 
in  FilterListWithOR(see the *filterRow()* in FilterListWithOR).

But if a cell return INCLUDE after f3's filterCell method, we can not drop all 
this row,  in FilterListWithOR's filterRow method, we need consider f3, only 
skip will loss result...

 

pls check it...thank you.

 

> FilterList with FuzzyRowFilter and SingleColumnValueFilter evaluated with 
> operator MUST_PASS_ONE doesn't work as expected
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-26967
>                 URL: https://issues.apache.org/jira/browse/HBASE-26967
>             Project: HBase
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 2.4.11
>            Reporter: Boris
>            Priority: Blocker
>
> I created test table with two column families by hbase shell:
>  
> {code:java}
> create 'test_table2', 'f1', 'f2'
> put 'test_table2', '1', 'f1:col1', 'a1'
> put 'test_table2', '1', 'f2:col2', 'a2'
> put 'test_table2', '2', 'f1:col1', 'b1'
> put 'test_table2', '2', 'f2:col2', 'b2' {code}
>  
>  
> The table contains of two rows (rowkeys '1' and '2'), tested FuzzyRowFilter 
> selects first row,
> SingleColumnValueFilter selects no rows, combination of both filters 
> evaluated with
> MUST_PASS_ONE operator returns surprisingly whole table. I prepared java 
> examples to
> show this strange behavior.
>  
> Code snippet below doesn't work as expected:
>  
> {code:java}
> try (Table table = connection.getTable(TableName.valueOf("test_table2"))) {
>     Scan scan = new Scan();
>     scan.addFamily(Bytes.toBytes("f1"));
>     scan.addFamily(Bytes.toBytes("f2"));
>     Filter fuzzyRowFilter = new FuzzyRowFilter(List.of(new 
> Pair<>(Bytes.toBytes("1"), new byte[] { 0x00 })));
>     scan.setFilter(fuzzyRowFilter);
>     System.out.println("result of fuzzy filter:");
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
>     System.out.println("result of single column value filter:");
>     Filter singleColumnValueFilter = new 
> SingleColumnValueFilter(Bytes.toBytes("f2"), Bytes.toBytes("col2"), 
> CompareOperator.EQUAL,
>             Bytes.toBytes("x"));
>     scan.setFilter(singleColumnValueFilter);
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
>     System.out.println("result of fuzzy or single column value filters:");
>     FilterList filterList = new FilterList(Operator.MUST_PASS_ONE);
>     filterList.addFilter(fuzzyRowFilter);
>     filterList.addFilter(singleColumnValueFilter);
>     scan.setFilter(filterList);
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
> } {code}
> Expected result in my opinion is:
>  
> {quote}result of fuzzy filter:
> 1
> result of single column value filter:
> result of fuzzy or single column value filters:
> 1
> {quote}
> But i am getting (NOT OK):
> {quote}result of fuzzy filter:
> 1
> result of single column value filter:
> result of fuzzy or single column value filters:
> 1
> 2
> {quote}
>  
> For tables with one column family or commentig out the line 
> _{color:#000000}scan{color}.addFamily({color:#000000}Bytes{color}.toBytes({color:#067d17}"f1"{color}))_
>  filter list evaluation is working OK. Similar example with PrefixFilter is 
> working like a charm:
>  
> {code:java}
> try (Table table = connection.getTable(TableName.valueOf("test_table2"))) {
>     Scan scan = new Scan();
>     scan.addFamily(Bytes.toBytes("f1"));
>     scan.addFamily(Bytes.toBytes("f2"));
>     Filter prefixFilter = new PrefixFilter(Bytes.toBytes("1"));
>     scan.setFilter(prefixFilter);
>     System.out.println("result of prefix filter:");
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
>     System.out.println("result of single column value filter:");
>     Filter singleColumnValueFilter = new 
> SingleColumnValueFilter(Bytes.toBytes("f2"), Bytes.toBytes("col2"), 
> CompareOperator.EQUAL,
>             Bytes.toBytes("x"));
>     scan.setFilter(singleColumnValueFilter);
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
>     System.out.println("result of prefix or single column value filters");
>     FilterList filterList = new FilterList(Operator.MUST_PASS_ONE);
>     filterList.addFilter(prefixFilter);
>     filterList.addFilter(singleColumnValueFilter);
>     scan.setFilter(filterList);
>     for (Result r : table.getScanner(scan)) {
>         System.out.println(Bytes.toString(r.getRow()));
>     }
> } {code}
>  
>  
> Result OK{_}:{_}
> {quote}result of prefix filter:
> 1
> result of single column value filter:
> result of prefix or single column value filters
> 1
> {quote}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to