You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@accumulo.apache.org by Lu Qin <lu...@gmail.com> on 2015/10/14 15:59:14 UTC

Why the Range not find the data

In my accumulo cluster ,the table has this data:
0 cf0:cq0 []    v0
1 cf1:cq1 []    v1

then I use scan to find it like this:
ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
                     new Key(new Text("0"), new Text("cf0")), true));
but it tell me #results=0.

 If i code like this:
ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
                     new Key(new Text("0"), new Text("cf00")), true));
it works OK.


api show me if I set true ,it will include the start and end key.Why I can not find the data ?

Thanks.

Re: Why the Range not find the data

Posted by Josh Elser <jo...@gmail.com>.
The key

     0 cf0:cq0

is greater than

     0 cf0:

(with an empty column qualifier).

This is why your first range finds nothing. Inclusivity is based on the 
entire key, not just the components of the key you provided.

Lu Qin wrote:
> In my accumulo cluster ,the table has this data:
> 0 cf0:cq0 [] v0
> 1 cf1:cq1 [] v1
>
> then I use scan to find it like this:
>
> ranges.add(newRange(newKey(newText("0"), newText("cf0")), true,
>                       newKey(newText("0"), newText("cf0")), true));
>
> but it tell me #results=0.
>
> If i code like this:
>
> ranges.add(newRange(newKey(newText("0"), newText("cf0")), true,
>                       newKey(newText("0"), newText("cf00")), true));
>
> it works OK.
>
>
> api show me if I set true ,it will include the start and end key.Why I
> can not find the data ?
>
> Thanks.

Re: Why the Range not find the data

Posted by Christopher <ct...@apache.org>.
Oh, sorry, Josh is right. My explanation is similar, and would apply if you
had specified the cq as well as the cf. I misread your code and did not
notice you had not specified cq in your range.

On Wed, Oct 14, 2015 at 10:53 AM Christopher <ct...@apache.org> wrote:

> The end key you've chosen in the first case occur before any of your data:
>
> The key is composed of: row, column family, column qualifier, column
> visibility, and timestamp. You've selected a key which would include
> everything up to, and including the column visibility, but the default
> timestamp it uses (Long.MAX_VALUE) would occur before any of your data
> (timestamps sort in reverse order to show most recent first). You can view
> timestamps with -st or --show-timestamps option on your scan command in the
> shell. Your data likely has a real timestamp (less than Long.MAX_VALUE) and
> would sort after.
>
> What you probably want is to specify the end key's CF as "cf0\0".
>
> On Wed, Oct 14, 2015 at 9:59 AM Lu Qin <lu...@gmail.com> wrote:
>
>> In my accumulo cluster ,the table has this data:
>> 0 cf0:cq0 []    v0
>> 1 cf1:cq1 []    v1
>>
>> then I use scan to find it like this:
>>
>> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>>                      new Key(new Text("0"), new Text("cf0")), true));
>>
>> but it tell me #results=0.
>>
>>  If i code like this:
>>
>> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>>                      new Key(new Text("0"), new Text("cf00")), true));
>>
>> it works OK.
>>
>>
>> api show me if I set true ,it will include the start and end key.Why I
>> can not find the data ?
>>
>> Thanks.
>>
>

Re: Why the Range not find the data

Posted by Christopher <ct...@apache.org>.
The end key you've chosen in the first case occur before any of your data:

The key is composed of: row, column family, column qualifier, column
visibility, and timestamp. You've selected a key which would include
everything up to, and including the column visibility, but the default
timestamp it uses (Long.MAX_VALUE) would occur before any of your data
(timestamps sort in reverse order to show most recent first). You can view
timestamps with -st or --show-timestamps option on your scan command in the
shell. Your data likely has a real timestamp (less than Long.MAX_VALUE) and
would sort after.

What you probably want is to specify the end key's CF as "cf0\0".

On Wed, Oct 14, 2015 at 9:59 AM Lu Qin <lu...@gmail.com> wrote:

> In my accumulo cluster ,the table has this data:
> 0 cf0:cq0 []    v0
> 1 cf1:cq1 []    v1
>
> then I use scan to find it like this:
>
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf0")), true));
>
> but it tell me #results=0.
>
>  If i code like this:
>
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf00")), true));
>
> it works OK.
>
>
> api show me if I set true ,it will include the start and end key.Why I can
> not find the data ?
>
> Thanks.
>

Re: Why the Range not find the data

Posted by Lu Qin <lu...@gmail.com>.
Thanks all.I have solve it by Range.exact

> 在 2015年10月15日,02:44,Adam Fuchs <af...@apache.org> 写道:
> 
> Try using the Range.exact(...) and Range.prefix(...) helper methods to generate specific ranges. Key.followingKey(...) might also be helpful.
> 
> Cheers,
> Adam
> 
> On Wed, Oct 14, 2015 at 9:59 AM, Lu Qin <luq.java@gmail.com <ma...@gmail.com>> wrote:
> In my accumulo cluster ,the table has this data:
> 0 cf0:cq0 []    v0
> 1 cf1:cq1 []    v1
> 
> then I use scan to find it like this:
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf0")), true));
> but it tell me #results=0.
> 
>  If i code like this:
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf00")), true));
> it works OK.
> 
> 
> api show me if I set true ,it will include the start and end key.Why I can not find the data ?
> 
> Thanks.
> 


Re: Why the Range not find the data

Posted by Adam Fuchs <af...@apache.org>.
Try using the Range.exact(...) and Range.prefix(...) helper methods to
generate specific ranges. Key.followingKey(...) might also be helpful.

Cheers,
Adam

On Wed, Oct 14, 2015 at 9:59 AM, Lu Qin <lu...@gmail.com> wrote:

> In my accumulo cluster ,the table has this data:
> 0 cf0:cq0 []    v0
> 1 cf1:cq1 []    v1
>
> then I use scan to find it like this:
>
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf0")), true));
>
> but it tell me #results=0.
>
>  If i code like this:
>
> ranges.add(new Range(new Key(new Text("0"), new Text("cf0")), true,
>                      new Key(new Text("0"), new Text("cf00")), true));
>
> it works OK.
>
>
> api show me if I set true ,it will include the start and end key.Why I can
> not find the data ?
>
> Thanks.
>