You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Shuja Rehman <sh...@gmail.com> on 2011/07/27 16:34:08 UTC

Filter Rows on last 4 bytes

Hi,

I have the key consist of two integers (4+4=8 Bytes). and i want to filter
the rows on the basis of second integer which means need to compare last 4
bytes of key. If last 4 bytes matched with input integer then row should
include in the return results. Can you ppl let me know how to do this with
java API.

Thanks

-- 
Regards
Shuja-ur-Rehman Baig
<http://pk.linkedin.com/in/shujamughal>

Re: Filter Rows on last 4 bytes

Posted by Jean-Daniel Cryans <jd...@apache.org>.
You need to write your own comparator (sorry if I didn't say it
plainly like that the first time).

J-D

On Fri, Jul 29, 2011 at 12:15 AM, Shuja Rehman <sh...@gmail.com> wrote:
> Yes, I have look that  But I did not find any comparator which takes
> starting index and length to match. I was thinking to have such type of
> comparator.
>
> Filter rf = new RowFilter(CompareOp.EQUAL, new
> BinaryComparator(Bytes.toBytes(ID), StartingIndex, Length);
>
> And, about restriction, yes first four bytes will give me a subset which
> further needs to filter on the basis of next 4 bytes.
>
>
> On Wed, Jul 27, 2011 at 11:45 PM, Jean-Daniel Cryans <jd...@apache.org>wrote:
>
>> You will need to use a RowFilter with a Comparator that only looks at
>> the last 4 bytes,
>>
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/RowFilter.html
>>
>> FYI unless you are restricting your scans on a few rows, doing this on
>> a whole table won't scale as it will do a full table scan.
>>
>> J-D
>>
>> On Wed, Jul 27, 2011 at 7:34 AM, Shuja Rehman <sh...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I have the key consist of two integers (4+4=8 Bytes). and i want to
>> filter
>> > the rows on the basis of second integer which means need to compare last
>> 4
>> > bytes of key. If last 4 bytes matched with input integer then row should
>> > include in the return results. Can you ppl let me know how to do this
>> with
>> > java API.
>> >
>> > Thanks
>> >
>> > --
>> > Regards
>> > Shuja-ur-Rehman Baig
>> > <http://pk.linkedin.com/in/shujamughal>
>> >
>>
>
>
>
> --
> Regards
> Shuja-ur-Rehman Baig
> <http://pk.linkedin.com/in/shujamughal>
>

Re: Filter Rows on last 4 bytes

Posted by Shuja Rehman <sh...@gmail.com>.
Yes, I have look that  But I did not find any comparator which takes
starting index and length to match. I was thinking to have such type of
comparator.

Filter rf = new RowFilter(CompareOp.EQUAL, new
BinaryComparator(Bytes.toBytes(ID), StartingIndex, Length);

And, about restriction, yes first four bytes will give me a subset which
further needs to filter on the basis of next 4 bytes.


On Wed, Jul 27, 2011 at 11:45 PM, Jean-Daniel Cryans <jd...@apache.org>wrote:

> You will need to use a RowFilter with a Comparator that only looks at
> the last 4 bytes,
>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/RowFilter.html
>
> FYI unless you are restricting your scans on a few rows, doing this on
> a whole table won't scale as it will do a full table scan.
>
> J-D
>
> On Wed, Jul 27, 2011 at 7:34 AM, Shuja Rehman <sh...@gmail.com>
> wrote:
> > Hi,
> >
> > I have the key consist of two integers (4+4=8 Bytes). and i want to
> filter
> > the rows on the basis of second integer which means need to compare last
> 4
> > bytes of key. If last 4 bytes matched with input integer then row should
> > include in the return results. Can you ppl let me know how to do this
> with
> > java API.
> >
> > Thanks
> >
> > --
> > Regards
> > Shuja-ur-Rehman Baig
> > <http://pk.linkedin.com/in/shujamughal>
> >
>



-- 
Regards
Shuja-ur-Rehman Baig
<http://pk.linkedin.com/in/shujamughal>

Re: Filter Rows on last 4 bytes

Posted by Jean-Daniel Cryans <jd...@apache.org>.
You will need to use a RowFilter with a Comparator that only looks at
the last 4 bytes,
http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/RowFilter.html

FYI unless you are restricting your scans on a few rows, doing this on
a whole table won't scale as it will do a full table scan.

J-D

On Wed, Jul 27, 2011 at 7:34 AM, Shuja Rehman <sh...@gmail.com> wrote:
> Hi,
>
> I have the key consist of two integers (4+4=8 Bytes). and i want to filter
> the rows on the basis of second integer which means need to compare last 4
> bytes of key. If last 4 bytes matched with input integer then row should
> include in the return results. Can you ppl let me know how to do this with
> java API.
>
> Thanks
>
> --
> Regards
> Shuja-ur-Rehman Baig
> <http://pk.linkedin.com/in/shujamughal>
>