hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Gray" <jl...@streamy.com>
Subject Re: Filtering by SingleColumnValueFilter
Date Thu, 03 Sep 2009 18:07:15 GMT
You are using FilterList.MUST_PASS_ONE... That is an OR condition.

You want FilterList.MUST_PASS_ALL if you want it to require both
conditions to be met.

If you want to include _other_ columns from that family if _these_ two
conditions are met (but the row skipped if the two conditions does not
match), then wrap the FilterList w/ a SkipFilter and use addFamily rather
than addColumns.  If you just want the row and the two columns you are
checking for, use addColumn calls and don't use the SkipFilter.

Hope that helps... and hope it works as you expect :)

Is there somewhere we could add better documentation?  FilterList should
explain AND/OR operations.

JG

On Thu, September 3, 2009 10:46 am, Adrian Olariu wrote:
> Thanks for quick replay, I want only the rows that matches BOTH
> conditions. Detailed: all the rows that have this two columns and the
> values from this two columns must match values specified in code.
>
> On Thu, Sep 3, 2009 at 8:37 PM, Jonathan Gray <jlist@streamy.com> wrote:
>
>
>> That filter just underwent a rewrite this week, there is certainly
>> possibility for a bug... However it does seem you are seeing expected
>> behavior.
>>
>> What exactly are you trying to do?  You want to return the entire row
>> if it makes the value (get all columns in the family if one column
>> matches), if it matches BOTH, if it matches EITHER... I don't follow
>> exactly what you want to have as the end result returned to the client.
>>
>> Could you define more specifically what you want your result to be?
>>
>>
>> JG
>>
>>
>> On Thu, September 3, 2009 10:08 am, Adrian Olariu wrote:
>>
>>> Hi,
>>> I'm trying to use some filters and the results are not like expected.
>>> Maybe there it's a bug. I'm using HBase 0.20.0 RC3
>>> I'm trying to filter rows using SingleColumnValueFilter like this:
>>> Scan s = new Scan();
>>>
>>>
>>>
>>> Filter filter1 = new SingleColumnValueFilter(Bytes.toBytes("F1"),
>>> Bytes.toBytes("c1"), CompareOp.EQUAL, Bytes.toBytes("1"));
>>> Filter filter2 = new SingleColumnValueFilter(Bytes.toBytes("F1"),
>>> Bytes.toBytes("c2"), CompareOp.EQUAL, Bytes.toBytes("1"));
>>> List<Filter> rowFilters = new ArrayList<Filter>();
>>> rowFilters.add(filter1);rowFilters.add(filter2); Filter filter = new
>>> FilterList(FilterList.Operator.MUST_PASS_ONE,
>>> rowFilters);
>>>
>>> s.addColumn(Bytes.toBytes("F1"), Bytes.toBytes("c1"));
>>> s.addColumn(Bytes.toBytes("F1"), Bytes.toBytes("c2"));
>>> s.setFilter(filter);
>>>
>>> long startTime = System.currentTimeMillis(); ResultScanner scanner =
>>> table.getScanner(s);
>>>
>>> This filter returns all rows the contains F1:c1 whit val "1" or
>>> contains F1:c2 whit val "1" or contains both.
>>> If I replace "addColumn" methods whit s.addFamily("F1"); the scanner
>>> returns all rows from the table whit no filtering eaven if the
>>> F1:c1/c2
>>> columns doesn't exist
>>>
>>> How can I get only the rows that matches all the conditions?
>>>
>>>
>>>
>>> Thank you,
>>> Olariu Adrian.
>>>
>>>
>>>
>>
>>
>


Mime
View raw message