You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Li Li <fa...@gmail.com> on 2014/03/25 04:36:23 UTC
how to calculate stop key for a scan?
I have two string as primary key(k1,k2)
and my row key in hbase is MD5(k1)MD5(k1)
I want to get all the rows equals k1.I can set startRowKey easily.
But How can I calculate stopRowKey?
is following correct? what if the last byte of md5 is 127? what about overflow?
any tools for this?
Scan scan=new Scan();
byte[] start=MD5(key1);
scan.setStartRow(start);
byte[] end=MD5(key1);
end[end.length-1]++
scan.setStopRow(end);
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
is it slower than scaner?
On Tue, Mar 25, 2014 at 11:48 AM, Ted Yu <yu...@gmail.com> wrote:
> Please consider using PrefixFilter where MD5(key1) is the prefix.
>
>
> On Mon, Mar 24, 2014 at 8:45 PM, Li Li <fa...@gmail.com> wrote:
>
>> sorry, I want to get all the rows startsWith k1
>> example:
>> k1 k2 rowKey
>> abc aaa -> MD5(abc)MD5(aaa)
>> abc bbb -> MD5(abc)MD5(bbb)
>> abd ddd -> MD5(abd)MD5(ddd)
>>
>> how to use scan to get all rows startswith abc
>>
>> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>> >>I want to get all the rows equals k1.
>> >
>> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>> >
>> >
>> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>> >
>> >> I have two string as primary key(k1,k2)
>> >> and my row key in hbase is MD5(k1)MD5(k1)
>> >> I want to get all the rows equals k1.I can set startRowKey easily.
>> >> But How can I calculate stopRowKey?
>> >> is following correct? what if the last byte of md5 is 127? what about
>> >> overflow?
>> >> any tools for this?
>> >>
>> >> Scan scan=new Scan();
>> >> byte[] start=MD5(key1);
>> >> scan.setStartRow(start);
>> >> byte[] end=MD5(key1);
>> >> end[end.length-1]++
>> >> scan.setStopRow(end);
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards,
>> > Haosdent Huang
>>
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
thank you
On Tue, Mar 25, 2014 at 11:48 AM, Ted Yu <yu...@gmail.com> wrote:
> Please consider using PrefixFilter where MD5(key1) is the prefix.
>
>
> On Mon, Mar 24, 2014 at 8:45 PM, Li Li <fa...@gmail.com> wrote:
>
>> sorry, I want to get all the rows startsWith k1
>> example:
>> k1 k2 rowKey
>> abc aaa -> MD5(abc)MD5(aaa)
>> abc bbb -> MD5(abc)MD5(bbb)
>> abd ddd -> MD5(abd)MD5(ddd)
>>
>> how to use scan to get all rows startswith abc
>>
>> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>> >>I want to get all the rows equals k1.
>> >
>> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>> >
>> >
>> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>> >
>> >> I have two string as primary key(k1,k2)
>> >> and my row key in hbase is MD5(k1)MD5(k1)
>> >> I want to get all the rows equals k1.I can set startRowKey easily.
>> >> But How can I calculate stopRowKey?
>> >> is following correct? what if the last byte of md5 is 127? what about
>> >> overflow?
>> >> any tools for this?
>> >>
>> >> Scan scan=new Scan();
>> >> byte[] start=MD5(key1);
>> >> scan.setStartRow(start);
>> >> byte[] end=MD5(key1);
>> >> end[end.length-1]++
>> >> scan.setStopRow(end);
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards,
>> > Haosdent Huang
>>
Re: how to calculate stop key for a scan?
Posted by Ted Yu <yu...@gmail.com>.
Please consider using PrefixFilter where MD5(key1) is the prefix.
On Mon, Mar 24, 2014 at 8:45 PM, Li Li <fa...@gmail.com> wrote:
> sorry, I want to get all the rows startsWith k1
> example:
> k1 k2 rowKey
> abc aaa -> MD5(abc)MD5(aaa)
> abc bbb -> MD5(abc)MD5(bbb)
> abd ddd -> MD5(abd)MD5(ddd)
>
> how to use scan to get all rows startswith abc
>
> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
> >>I want to get all the rows equals k1.
> >
> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
> >
> >
> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
> >
> >> I have two string as primary key(k1,k2)
> >> and my row key in hbase is MD5(k1)MD5(k1)
> >> I want to get all the rows equals k1.I can set startRowKey easily.
> >> But How can I calculate stopRowKey?
> >> is following correct? what if the last byte of md5 is 127? what about
> >> overflow?
> >> any tools for this?
> >>
> >> Scan scan=new Scan();
> >> byte[] start=MD5(key1);
> >> scan.setStartRow(start);
> >> byte[] end=MD5(key1);
> >> end[end.length-1]++
> >> scan.setStopRow(end);
> >>
> >
> >
> >
> > --
> > Best Regards,
> > Haosdent Huang
>
Re: how to calculate stop key for a scan?
Posted by Esteban Gutierrez <es...@cloudera.com>.
Hi Li,
option 1 should be better for you, as discussed few days ago here due
HBASE-7010 you need to specify the start row.
esteban.
--
Cloudera, Inc.
On Mon, Mar 24, 2014 at 9:42 PM, Li Li <fa...@gmail.com> wrote:
> 1.
> byte[] md5=DigestUtils.md5(k1);
> Scan scan=new Scan();
> scan.setStartRow(md5);
> scan.setFilter(new PrefixFilter(md5));
>
> 2.
> byte[] md5=DigestUtils.md5(k1);
> Scan scan=new Scan();
> scan.setFilter(new PrefixFilter(md5));
>
> will code snipplet1 be faster than 2?
>
> On Tue, Mar 25, 2014 at 12:38 PM, Li Li <fa...@gmail.com> wrote:
> > thanks. it should work for my use cases(append a char larger than any
> > char used by md5), but I think prefixfilter is more better and can be
> > used without worry about any details
> >
> > On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
> > <es...@cloudera.com> wrote:
> >> Hello Li.
> >>
> >> Have you tried to do something as simple as appending ~ (ascii 7E, last
> >> printable ascii symbol) at the end of the start key as the stop key? It
> >> should work find for you:
> >>
> >>
> >> hbase(main):001:0> put 't1',
> >> '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29',
> 'c1',
> >> 'A'
> >> hbase(main):002:0> put 't1',
> >> '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571',
> 'c1',
> >> 'B'
> >> hbase(main):003:0> put 't1',
> >> '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571',
> 'c1',
> >> 'AB'
> >> hbase(main):004:0> scan 't1',
> >> {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
> >> ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
> >> ROW COLUMN+CELL
> >> 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
> >> timestamp=1395721490980, value=A
> >> 7a70fa81a5935b72eacbe29
> >> 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
> >> timestamp=1395721814374, value=AB
> >> e57bcca610140957afab571
> >> 2 row(s) in 0.0210 seconds
> >>
> >>
> >> esteban.
> >>
> >>
> >>
> >> --
> >> Cloudera, Inc.
> >>
> >>
> >>
> >> On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
> >>
> >>> have you understand the question? how to get the 'next' string of a
> >>> given string?
> >>>
> >>> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
> >>> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
> >>> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and
> set
> >>> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
> >>> >
> >>> >
> >>> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
> >>> >
> >>> >> sorry, I want to get all the rows startsWith k1
> >>> >> example:
> >>> >> k1 k2 rowKey
> >>> >> abc aaa -> MD5(abc)MD5(aaa)
> >>> >> abc bbb -> MD5(abc)MD5(bbb)
> >>> >> abd ddd -> MD5(abd)MD5(ddd)
> >>> >>
> >>> >> how to use scan to get all rows startswith abc
> >>> >>
> >>> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com>
> wrote:
> >>> >> >>I want to get all the rows equals k1.
> >>> >> >
> >>> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
> >>> >> >
> >>> >> >
> >>> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com>
> wrote:
> >>> >> >
> >>> >> >> I have two string as primary key(k1,k2)
> >>> >> >> and my row key in hbase is MD5(k1)MD5(k1)
> >>> >> >> I want to get all the rows equals k1.I can set startRowKey
> easily.
> >>> >> >> But How can I calculate stopRowKey?
> >>> >> >> is following correct? what if the last byte of md5 is 127? what
> about
> >>> >> >> overflow?
> >>> >> >> any tools for this?
> >>> >> >>
> >>> >> >> Scan scan=new Scan();
> >>> >> >> byte[] start=MD5(key1);
> >>> >> >> scan.setStartRow(start);
> >>> >> >> byte[] end=MD5(key1);
> >>> >> >> end[end.length-1]++
> >>> >> >> scan.setStopRow(end);
> >>> >> >>
> >>> >> >
> >>> >> >
> >>> >> >
> >>> >> > --
> >>> >> > Best Regards,
> >>> >> > Haosdent Huang
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > Best Regards,
> >>> > Haosdent Huang
> >>>
>
Re: how to calculate stop key for a scan?
Posted by Ted Yu <yu...@gmail.com>.
Snippet 2 is wrong - to use PrefixFilter, start row needs to be specified.
Cheers
On Mar 24, 2014, at 9:42 PM, Li Li <fa...@gmail.com> wrote:
> 1.
> byte[] md5=DigestUtils.md5(k1);
> Scan scan=new Scan();
> scan.setStartRow(md5);
> scan.setFilter(new PrefixFilter(md5));
>
> 2.
> byte[] md5=DigestUtils.md5(k1);
> Scan scan=new Scan();
> scan.setFilter(new PrefixFilter(md5));
>
> will code snipplet1 be faster than 2?
>
> On Tue, Mar 25, 2014 at 12:38 PM, Li Li <fa...@gmail.com> wrote:
>> thanks. it should work for my use cases(append a char larger than any
>> char used by md5), but I think prefixfilter is more better and can be
>> used without worry about any details
>>
>> On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
>> <es...@cloudera.com> wrote:
>>> Hello Li.
>>>
>>> Have you tried to do something as simple as appending ~ (ascii 7E, last
>>> printable ascii symbol) at the end of the start key as the stop key? It
>>> should work find for you:
>>>
>>>
>>> hbase(main):001:0> put 't1',
>>> '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
>>> 'A'
>>> hbase(main):002:0> put 't1',
>>> '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
>>> 'B'
>>> hbase(main):003:0> put 't1',
>>> '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
>>> 'AB'
>>> hbase(main):004:0> scan 't1',
>>> {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
>>> ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
>>> ROW COLUMN+CELL
>>> 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
>>> timestamp=1395721490980, value=A
>>> 7a70fa81a5935b72eacbe29
>>> 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
>>> timestamp=1395721814374, value=AB
>>> e57bcca610140957afab571
>>> 2 row(s) in 0.0210 seconds
>>>
>>>
>>> esteban.
>>>
>>>
>>>
>>> --
>>> Cloudera, Inc.
>>>
>>>
>>>
>>> On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
>>>
>>>> have you understand the question? how to get the 'next' string of a
>>>> given string?
>>>>
>>>> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
>>>>> MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
>>>>> So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
>>>>> stopkey to "900150983cd24fb0d6963f7d28e17f73".
>>>>>
>>>>>
>>>>> On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
>>>>>
>>>>>> sorry, I want to get all the rows startsWith k1
>>>>>> example:
>>>>>> k1 k2 rowKey
>>>>>> abc aaa -> MD5(abc)MD5(aaa)
>>>>>> abc bbb -> MD5(abc)MD5(bbb)
>>>>>> abd ddd -> MD5(abd)MD5(ddd)
>>>>>>
>>>>>> how to use scan to get all rows startswith abc
>>>>>>
>>>>>> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>>>>>>>> I want to get all the rows equals k1.
>>>>>>>
>>>>>>> Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>>>>>>>
>>>>>>>> I have two string as primary key(k1,k2)
>>>>>>>> and my row key in hbase is MD5(k1)MD5(k1)
>>>>>>>> I want to get all the rows equals k1.I can set startRowKey easily.
>>>>>>>> But How can I calculate stopRowKey?
>>>>>>>> is following correct? what if the last byte of md5 is 127? what about
>>>>>>>> overflow?
>>>>>>>> any tools for this?
>>>>>>>>
>>>>>>>> Scan scan=new Scan();
>>>>>>>> byte[] start=MD5(key1);
>>>>>>>> scan.setStartRow(start);
>>>>>>>> byte[] end=MD5(key1);
>>>>>>>> end[end.length-1]++
>>>>>>>> scan.setStopRow(end);
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Haosdent Huang
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>> Haosdent Huang
>>>>
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
1.
byte[] md5=DigestUtils.md5(k1);
Scan scan=new Scan();
scan.setStartRow(md5);
scan.setFilter(new PrefixFilter(md5));
2.
byte[] md5=DigestUtils.md5(k1);
Scan scan=new Scan();
scan.setFilter(new PrefixFilter(md5));
will code snipplet1 be faster than 2?
On Tue, Mar 25, 2014 at 12:38 PM, Li Li <fa...@gmail.com> wrote:
> thanks. it should work for my use cases(append a char larger than any
> char used by md5), but I think prefixfilter is more better and can be
> used without worry about any details
>
> On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
> <es...@cloudera.com> wrote:
>> Hello Li.
>>
>> Have you tried to do something as simple as appending ~ (ascii 7E, last
>> printable ascii symbol) at the end of the start key as the stop key? It
>> should work find for you:
>>
>>
>> hbase(main):001:0> put 't1',
>> '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
>> 'A'
>> hbase(main):002:0> put 't1',
>> '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
>> 'B'
>> hbase(main):003:0> put 't1',
>> '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
>> 'AB'
>> hbase(main):004:0> scan 't1',
>> {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
>> ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
>> ROW COLUMN+CELL
>> 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
>> timestamp=1395721490980, value=A
>> 7a70fa81a5935b72eacbe29
>> 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
>> timestamp=1395721814374, value=AB
>> e57bcca610140957afab571
>> 2 row(s) in 0.0210 seconds
>>
>>
>> esteban.
>>
>>
>>
>> --
>> Cloudera, Inc.
>>
>>
>>
>> On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
>>
>>> have you understand the question? how to get the 'next' string of a
>>> given string?
>>>
>>> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
>>> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
>>> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
>>> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
>>> >
>>> >
>>> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
>>> >
>>> >> sorry, I want to get all the rows startsWith k1
>>> >> example:
>>> >> k1 k2 rowKey
>>> >> abc aaa -> MD5(abc)MD5(aaa)
>>> >> abc bbb -> MD5(abc)MD5(bbb)
>>> >> abd ddd -> MD5(abd)MD5(ddd)
>>> >>
>>> >> how to use scan to get all rows startswith abc
>>> >>
>>> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>>> >> >>I want to get all the rows equals k1.
>>> >> >
>>> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>>> >> >
>>> >> >
>>> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>>> >> >
>>> >> >> I have two string as primary key(k1,k2)
>>> >> >> and my row key in hbase is MD5(k1)MD5(k1)
>>> >> >> I want to get all the rows equals k1.I can set startRowKey easily.
>>> >> >> But How can I calculate stopRowKey?
>>> >> >> is following correct? what if the last byte of md5 is 127? what about
>>> >> >> overflow?
>>> >> >> any tools for this?
>>> >> >>
>>> >> >> Scan scan=new Scan();
>>> >> >> byte[] start=MD5(key1);
>>> >> >> scan.setStartRow(start);
>>> >> >> byte[] end=MD5(key1);
>>> >> >> end[end.length-1]++
>>> >> >> scan.setStopRow(end);
>>> >> >>
>>> >> >
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Best Regards,
>>> >> > Haosdent Huang
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Best Regards,
>>> > Haosdent Huang
>>>
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
thanks. it should work for my use cases(append a char larger than any
char used by md5), but I think prefixfilter is more better and can be
used without worry about any details
On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
<es...@cloudera.com> wrote:
> Hello Li.
>
> Have you tried to do something as simple as appending ~ (ascii 7E, last
> printable ascii symbol) at the end of the start key as the stop key? It
> should work find for you:
>
>
> hbase(main):001:0> put 't1',
> '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
> 'A'
> hbase(main):002:0> put 't1',
> '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
> 'B'
> hbase(main):003:0> put 't1',
> '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
> 'AB'
> hbase(main):004:0> scan 't1',
> {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
> ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
> ROW COLUMN+CELL
> 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
> timestamp=1395721490980, value=A
> 7a70fa81a5935b72eacbe29
> 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
> timestamp=1395721814374, value=AB
> e57bcca610140957afab571
> 2 row(s) in 0.0210 seconds
>
>
> esteban.
>
>
>
> --
> Cloudera, Inc.
>
>
>
> On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
>
>> have you understand the question? how to get the 'next' string of a
>> given string?
>>
>> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
>> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
>> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
>> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
>> >
>> >
>> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
>> >
>> >> sorry, I want to get all the rows startsWith k1
>> >> example:
>> >> k1 k2 rowKey
>> >> abc aaa -> MD5(abc)MD5(aaa)
>> >> abc bbb -> MD5(abc)MD5(bbb)
>> >> abd ddd -> MD5(abd)MD5(ddd)
>> >>
>> >> how to use scan to get all rows startswith abc
>> >>
>> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>> >> >>I want to get all the rows equals k1.
>> >> >
>> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>> >> >
>> >> >
>> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>> >> >
>> >> >> I have two string as primary key(k1,k2)
>> >> >> and my row key in hbase is MD5(k1)MD5(k1)
>> >> >> I want to get all the rows equals k1.I can set startRowKey easily.
>> >> >> But How can I calculate stopRowKey?
>> >> >> is following correct? what if the last byte of md5 is 127? what about
>> >> >> overflow?
>> >> >> any tools for this?
>> >> >>
>> >> >> Scan scan=new Scan();
>> >> >> byte[] start=MD5(key1);
>> >> >> scan.setStartRow(start);
>> >> >> byte[] end=MD5(key1);
>> >> >> end[end.length-1]++
>> >> >> scan.setStopRow(end);
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Best Regards,
>> >> > Haosdent Huang
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards,
>> > Haosdent Huang
>>
Re: how to calculate stop key for a scan?
Posted by Esteban Gutierrez <es...@cloudera.com>.
Hello Li,
Same concept applies, try using 0xFF if using bytes for the key.
esteban.
--
Cloudera, Inc.
On Mon, Mar 24, 2014 at 10:17 PM, Li Li <fa...@gmail.com> wrote:
> my rowkey is not a string md5(k1)md5(k1) but the raw bytes
> md5(k1) return the raw bytes instead of hex of this string.
> the codes:
> byte[] array1=DigestUtils.md5(k1);
> byte[] array2=DigestUtils.md5(k2);
> Put put=new Put(Bytes.add(array1, array2));
> ...
>
> On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
> <es...@cloudera.com> wrote:
> > Hello Li.
> >
> > Have you tried to do something as simple as appending ~ (ascii 7E, last
> > printable ascii symbol) at the end of the start key as the stop key? It
> > should work find for you:
> >
> >
> > hbase(main):001:0> put 't1',
> > '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
> > 'A'
> > hbase(main):002:0> put 't1',
> > '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
> > 'B'
> > hbase(main):003:0> put 't1',
> > '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
> > 'AB'
> > hbase(main):004:0> scan 't1',
> > {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
> > ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
> > ROW COLUMN+CELL
> > 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
> > timestamp=1395721490980, value=A
> > 7a70fa81a5935b72eacbe29
> > 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
> > timestamp=1395721814374, value=AB
> > e57bcca610140957afab571
> > 2 row(s) in 0.0210 seconds
> >
> >
> > esteban.
> >
> >
> >
> > --
> > Cloudera, Inc.
> >
> >
> >
> > On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
> >
> >> have you understand the question? how to get the 'next' string of a
> >> given string?
> >>
> >> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
> >> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
> >> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and
> set
> >> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
> >> >
> >> >
> >> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
> >> >
> >> >> sorry, I want to get all the rows startsWith k1
> >> >> example:
> >> >> k1 k2 rowKey
> >> >> abc aaa -> MD5(abc)MD5(aaa)
> >> >> abc bbb -> MD5(abc)MD5(bbb)
> >> >> abd ddd -> MD5(abd)MD5(ddd)
> >> >>
> >> >> how to use scan to get all rows startswith abc
> >> >>
> >> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com>
> wrote:
> >> >> >>I want to get all the rows equals k1.
> >> >> >
> >> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
> >> >> >
> >> >> >
> >> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com>
> wrote:
> >> >> >
> >> >> >> I have two string as primary key(k1,k2)
> >> >> >> and my row key in hbase is MD5(k1)MD5(k1)
> >> >> >> I want to get all the rows equals k1.I can set startRowKey easily.
> >> >> >> But How can I calculate stopRowKey?
> >> >> >> is following correct? what if the last byte of md5 is 127? what
> about
> >> >> >> overflow?
> >> >> >> any tools for this?
> >> >> >>
> >> >> >> Scan scan=new Scan();
> >> >> >> byte[] start=MD5(key1);
> >> >> >> scan.setStartRow(start);
> >> >> >> byte[] end=MD5(key1);
> >> >> >> end[end.length-1]++
> >> >> >> scan.setStopRow(end);
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Best Regards,
> >> >> > Haosdent Huang
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Best Regards,
> >> > Haosdent Huang
> >>
>
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
my rowkey is not a string md5(k1)md5(k1) but the raw bytes
md5(k1) return the raw bytes instead of hex of this string.
the codes:
byte[] array1=DigestUtils.md5(k1);
byte[] array2=DigestUtils.md5(k2);
Put put=new Put(Bytes.add(array1, array2));
...
On Tue, Mar 25, 2014 at 12:33 PM, Esteban Gutierrez
<es...@cloudera.com> wrote:
> Hello Li.
>
> Have you tried to do something as simple as appending ~ (ascii 7E, last
> printable ascii symbol) at the end of the start key as the stop key? It
> should work find for you:
>
>
> hbase(main):001:0> put 't1',
> '7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
> 'A'
> hbase(main):002:0> put 't1',
> '9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
> 'B'
> hbase(main):003:0> put 't1',
> '7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
> 'AB'
> hbase(main):004:0> scan 't1',
> {STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
> ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
> ROW COLUMN+CELL
> 7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
> timestamp=1395721490980, value=A
> 7a70fa81a5935b72eacbe29
> 7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
> timestamp=1395721814374, value=AB
> e57bcca610140957afab571
> 2 row(s) in 0.0210 seconds
>
>
> esteban.
>
>
>
> --
> Cloudera, Inc.
>
>
>
> On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
>
>> have you understand the question? how to get the 'next' string of a
>> given string?
>>
>> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
>> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
>> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
>> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
>> >
>> >
>> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
>> >
>> >> sorry, I want to get all the rows startsWith k1
>> >> example:
>> >> k1 k2 rowKey
>> >> abc aaa -> MD5(abc)MD5(aaa)
>> >> abc bbb -> MD5(abc)MD5(bbb)
>> >> abd ddd -> MD5(abd)MD5(ddd)
>> >>
>> >> how to use scan to get all rows startswith abc
>> >>
>> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>> >> >>I want to get all the rows equals k1.
>> >> >
>> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>> >> >
>> >> >
>> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>> >> >
>> >> >> I have two string as primary key(k1,k2)
>> >> >> and my row key in hbase is MD5(k1)MD5(k1)
>> >> >> I want to get all the rows equals k1.I can set startRowKey easily.
>> >> >> But How can I calculate stopRowKey?
>> >> >> is following correct? what if the last byte of md5 is 127? what about
>> >> >> overflow?
>> >> >> any tools for this?
>> >> >>
>> >> >> Scan scan=new Scan();
>> >> >> byte[] start=MD5(key1);
>> >> >> scan.setStartRow(start);
>> >> >> byte[] end=MD5(key1);
>> >> >> end[end.length-1]++
>> >> >> scan.setStopRow(end);
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Best Regards,
>> >> > Haosdent Huang
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards,
>> > Haosdent Huang
>>
Re: how to calculate stop key for a scan?
Posted by Esteban Gutierrez <es...@cloudera.com>.
Hello Li.
Have you tried to do something as simple as appending ~ (ascii 7E, last
printable ascii symbol) at the end of the start key as the stop key? It
should work find for you:
hbase(main):001:0> put 't1',
'7fc56270e7a70fa81a5935b72eacbe297fc56270e7a70fa81a5935b72eacbe29', 'c1',
'A'
hbase(main):002:0> put 't1',
'9d5ed678fe57bcca610140957afab5719d5ed678fe57bcca610140957afab571', 'c1',
'B'
hbase(main):003:0> put 't1',
'7fc56270e7a70fa81a5935b72eacbe299d5ed678fe57bcca610140957afab571', 'c1',
'AB'
hbase(main):004:0> scan 't1',
{STARTROW=>'7fc56270e7a70fa81a5935b72eacbe29',
ENDROW=>'7fc56270e7a70fa81a5935b72eacbe29~'}
ROW COLUMN+CELL
7fc56270e7a70fa81a5935b72eacbe297fc56270e column=c1:,
timestamp=1395721490980, value=A
7a70fa81a5935b72eacbe29
7fc56270e7a70fa81a5935b72eacbe299d5ed678f column=c1:,
timestamp=1395721814374, value=AB
e57bcca610140957afab571
2 row(s) in 0.0210 seconds
esteban.
--
Cloudera, Inc.
On Mon, Mar 24, 2014 at 9:17 PM, Li Li <fa...@gmail.com> wrote:
> have you understand the question? how to get the 'next' string of a
> given string?
>
> On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
> > MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
> > So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
> > stopkey to "900150983cd24fb0d6963f7d28e17f73".
> >
> >
> > On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
> >
> >> sorry, I want to get all the rows startsWith k1
> >> example:
> >> k1 k2 rowKey
> >> abc aaa -> MD5(abc)MD5(aaa)
> >> abc bbb -> MD5(abc)MD5(bbb)
> >> abd ddd -> MD5(abd)MD5(ddd)
> >>
> >> how to use scan to get all rows startswith abc
> >>
> >> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
> >> >>I want to get all the rows equals k1.
> >> >
> >> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
> >> >
> >> >
> >> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
> >> >
> >> >> I have two string as primary key(k1,k2)
> >> >> and my row key in hbase is MD5(k1)MD5(k1)
> >> >> I want to get all the rows equals k1.I can set startRowKey easily.
> >> >> But How can I calculate stopRowKey?
> >> >> is following correct? what if the last byte of md5 is 127? what about
> >> >> overflow?
> >> >> any tools for this?
> >> >>
> >> >> Scan scan=new Scan();
> >> >> byte[] start=MD5(key1);
> >> >> scan.setStartRow(start);
> >> >> byte[] end=MD5(key1);
> >> >> end[end.length-1]++
> >> >> scan.setStopRow(end);
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Best Regards,
> >> > Haosdent Huang
> >>
> >
> >
> >
> > --
> > Best Regards,
> > Haosdent Huang
>
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
have you understand the question? how to get the 'next' string of a
given string?
On Tue, Mar 25, 2014 at 11:49 AM, haosdent <ha...@gmail.com> wrote:
> MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
> So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
> stopkey to "900150983cd24fb0d6963f7d28e17f73".
>
>
> On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
>
>> sorry, I want to get all the rows startsWith k1
>> example:
>> k1 k2 rowKey
>> abc aaa -> MD5(abc)MD5(aaa)
>> abc bbb -> MD5(abc)MD5(bbb)
>> abd ddd -> MD5(abd)MD5(ddd)
>>
>> how to use scan to get all rows startswith abc
>>
>> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>> >>I want to get all the rows equals k1.
>> >
>> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>> >
>> >
>> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>> >
>> >> I have two string as primary key(k1,k2)
>> >> and my row key in hbase is MD5(k1)MD5(k1)
>> >> I want to get all the rows equals k1.I can set startRowKey easily.
>> >> But How can I calculate stopRowKey?
>> >> is following correct? what if the last byte of md5 is 127? what about
>> >> overflow?
>> >> any tools for this?
>> >>
>> >> Scan scan=new Scan();
>> >> byte[] start=MD5(key1);
>> >> scan.setStartRow(start);
>> >> byte[] end=MD5(key1);
>> >> end[end.length-1]++
>> >> scan.setStopRow(end);
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards,
>> > Haosdent Huang
>>
>
>
>
> --
> Best Regards,
> Haosdent Huang
Re: how to calculate stop key for a scan?
Posted by haosdent <ha...@gmail.com>.
MD5(abc) = "900150983cd24fb0d6963f7d28e17f72"
So you could set startkey to "900150983cd24fb0d6963f7d28e17f72" and set
stopkey to "900150983cd24fb0d6963f7d28e17f73".
On Tue, Mar 25, 2014 at 11:45 AM, Li Li <fa...@gmail.com> wrote:
> sorry, I want to get all the rows startsWith k1
> example:
> k1 k2 rowKey
> abc aaa -> MD5(abc)MD5(aaa)
> abc bbb -> MD5(abc)MD5(bbb)
> abd ddd -> MD5(abd)MD5(ddd)
>
> how to use scan to get all rows startswith abc
>
> On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
> >>I want to get all the rows equals k1.
> >
> > Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
> >
> >
> > On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
> >
> >> I have two string as primary key(k1,k2)
> >> and my row key in hbase is MD5(k1)MD5(k1)
> >> I want to get all the rows equals k1.I can set startRowKey easily.
> >> But How can I calculate stopRowKey?
> >> is following correct? what if the last byte of md5 is 127? what about
> >> overflow?
> >> any tools for this?
> >>
> >> Scan scan=new Scan();
> >> byte[] start=MD5(key1);
> >> scan.setStartRow(start);
> >> byte[] end=MD5(key1);
> >> end[end.length-1]++
> >> scan.setStopRow(end);
> >>
> >
> >
> >
> > --
> > Best Regards,
> > Haosdent Huang
>
--
Best Regards,
Haosdent Huang
Re: how to calculate stop key for a scan?
Posted by Li Li <fa...@gmail.com>.
sorry, I want to get all the rows startsWith k1
example:
k1 k2 rowKey
abc aaa -> MD5(abc)MD5(aaa)
abc bbb -> MD5(abc)MD5(bbb)
abd ddd -> MD5(abd)MD5(ddd)
how to use scan to get all rows startswith abc
On Tue, Mar 25, 2014 at 11:40 AM, haosdent <ha...@gmail.com> wrote:
>>I want to get all the rows equals k1.
>
> Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
>
>
> On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
>
>> I have two string as primary key(k1,k2)
>> and my row key in hbase is MD5(k1)MD5(k1)
>> I want to get all the rows equals k1.I can set startRowKey easily.
>> But How can I calculate stopRowKey?
>> is following correct? what if the last byte of md5 is 127? what about
>> overflow?
>> any tools for this?
>>
>> Scan scan=new Scan();
>> byte[] start=MD5(key1);
>> scan.setStartRow(start);
>> byte[] end=MD5(key1);
>> end[end.length-1]++
>> scan.setStopRow(end);
>>
>
>
>
> --
> Best Regards,
> Haosdent Huang
Re: how to calculate stop key for a scan?
Posted by haosdent <ha...@gmail.com>.
>I want to get all the rows equals k1.
Use Get(MD5(k1)MD5(k1)) without set startkey and stopkey.
On Tue, Mar 25, 2014 at 11:36 AM, Li Li <fa...@gmail.com> wrote:
> I have two string as primary key(k1,k2)
> and my row key in hbase is MD5(k1)MD5(k1)
> I want to get all the rows equals k1.I can set startRowKey easily.
> But How can I calculate stopRowKey?
> is following correct? what if the last byte of md5 is 127? what about
> overflow?
> any tools for this?
>
> Scan scan=new Scan();
> byte[] start=MD5(key1);
> scan.setStartRow(start);
> byte[] end=MD5(key1);
> end[end.length-1]++
> scan.setStopRow(end);
>
--
Best Regards,
Haosdent Huang