You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@accumulo.apache.org by Ryan <fr...@gmail.com> on 2014/07/17 17:03:22 UTC

Scanning over a range of column families?

Hi, I'm learning Accumulo and am attempting to write a Java client that
scans over an Accumulo table using a single row id and a range of column
families. Going through the API, the closest thing I've found to this
feature is the 'bound method:

scan.setRange(new Range(entity).bound(new Column(startTime.getBytes(),
"0".getBytes(), "public".getBytes()), new Column(endTime.getBytes(),
"1".getBytes(), "public".getBytes())));

Is there a simpler way to do this without a need to include the visibility
or column qualifier?

The API version I'm using is 1.5.1.

Re: Scanning over a range of column families?

Posted by Ryan <fr...@gmail.com>.
Ah okay. That makes sense for if I just want one rowID with a variety of
column families. For multiple RowIDs, I'm assuming I'd use the earlier
mentioned:

scan.setRange(new Range(new Key(singleRowId.getBytes(),
startTime.getBytes(), "0".getBytes()), true, new
Key(singleRowId.getBytes(), endTime.getBytes(), "1".getBytes()), true);


On Thu, Jul 17, 2014 at 12:34 PM, Josh Elser <jo...@gmail.com> wrote:

> Oh, ok, that example isn't doing *quite* what you expect it to be doing.
> It's only going to match the Key which is the row of entityUID with empty
> cf/cq/cv/etc. It's a little confusing at first glance.
>
> For the entire row, you can use the convince static method on range:
>
> Range.exact(entityUID)
>
> or the underlying constructor
>
> new Range(entityUID)
>
>
> On 7/17/14, 12:21 PM, Ryan wrote:
>
>> Okay, that makes sense. I also tried it with scan.setRange(new Range(new
>> Key(entityUID), new Key(entityUID))); to the same results. Still no
>> entries being returned (and hence nothing printing to screen) when I run:
>>
>> //iterate through the entries and print them to the console
>> for(Entry<Key,Value> entry : scan){
>> System.out.println("Printing entries from scan");
>> System.out.println(entry.getKey().toString() + " -> " +
>> entry.getValue().toString());
>> }
>>
>>
>> On Thu, Jul 17, 2014 at 12:11 PM, Josh Elser <josh.elser@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>>     I think by default both Keys provided to a Range are inclusive, when
>>     using the 4-argument Range constructor, the 2nd and 4th arguments
>>     are boolean controlling the inclusivity of the 1st and 3rd argument,
>>     respectively.
>>
>>     If you invoke any of the fetchColumnFamily/fetchColumns methods,
>>     they match up with the columns you're scanning over. It is possible
>>     to preclude yourself from getting columns if you 'fetch' other
>>     columns. If you don't invoke these methods, Accumulo will return you
>>     all columns.
>>
>>     Perhaps you can narrow down your problem using a range for the whole
>>     row and then try more restricted ranges.
>>
>>
>>     On 7/17/14, 11:59 AM, Ryan wrote:
>>
>>         Thanks, that's much simpler. I looked into the API docs for the
>> Key
>>         class and found a way to get it down to just: scan.setRange(new
>>         Range(new Key(entityUID, startTime), new Key(entityUID,
>> endTime)));
>>
>>         Unfortunately, that doesn't return any results. Is the scan
>>         inclusive?
>>         Is it not including the byte array values that is messing it up?
>>         I know
>>         the problem isn't with the connection because scanning the table
>>         without
>>         any range values from my program works.
>>
>>
>>         On Thu, Jul 17, 2014 at 11:09 AM, Josh Elser
>>         <josh.elser@gmail.com <ma...@gmail.com>
>>         <mailto:josh.elser@gmail.com <ma...@gmail.com>>>
>> wrote:
>>
>>              Sure is. Just provide a start Key and end Key.
>>
>>              scan.setRange(new Range(new Key(singleRowId.getBytes(),
>>              startTime.getBytes(), "0".getBytes()), true, new
>>              Key(singleRowId.getBytes(), endTime.getBytes(),
>>         "1".getBytes()), true);
>>
>>              The range spans the single row you are interested in, and
>>         you can
>>              specify up to the column qualifier for the start and end
>>         key. If you
>>              don't specify the visibility of timestamp, you would end up
>>         getting
>>              all key-values (cv,timestamp,value) between those two keys.
>>
>>
>>              On 7/17/14, 11:03 AM, Ryan wrote:
>>
>>                  Hi, I'm learning Accumulo and am attempting to write a
>> Java
>>                  client that
>>                  scans over an Accumulo table using a single row id and
>>         a range
>>                  of column
>>                  families. Going through the API, the closest thing I've
>>         found to
>>                  this
>>                  feature is the 'bound method:
>>
>>                  scan.setRange(new Range(entity).bound(new
>>                  Column(startTime.getBytes(),
>>                  "0".getBytes(), "public".getBytes()), new
>>         Column(endTime.getBytes(),
>>                  "1".getBytes(), "public".getBytes())));
>>
>>                  Is there a simpler way to do this without a need to
>>         include the
>>                  visibility or column qualifier?
>>
>>                  The API version I'm using is 1.5.1.
>>
>>
>>
>>

Re: Scanning over a range of column families?

Posted by Josh Elser <jo...@gmail.com>.
Oh, ok, that example isn't doing *quite* what you expect it to be doing. 
It's only going to match the Key which is the row of entityUID with 
empty cf/cq/cv/etc. It's a little confusing at first glance.

For the entire row, you can use the convince static method on range:

Range.exact(entityUID)

or the underlying constructor

new Range(entityUID)

On 7/17/14, 12:21 PM, Ryan wrote:
> Okay, that makes sense. I also tried it with scan.setRange(new Range(new
> Key(entityUID), new Key(entityUID))); to the same results. Still no
> entries being returned (and hence nothing printing to screen) when I run:
>
> //iterate through the entries and print them to the console
> for(Entry<Key,Value> entry : scan){
> System.out.println("Printing entries from scan");
> System.out.println(entry.getKey().toString() + " -> " +
> entry.getValue().toString());
> }
>
>
> On Thu, Jul 17, 2014 at 12:11 PM, Josh Elser <josh.elser@gmail.com
> <ma...@gmail.com>> wrote:
>
>     I think by default both Keys provided to a Range are inclusive, when
>     using the 4-argument Range constructor, the 2nd and 4th arguments
>     are boolean controlling the inclusivity of the 1st and 3rd argument,
>     respectively.
>
>     If you invoke any of the fetchColumnFamily/fetchColumns methods,
>     they match up with the columns you're scanning over. It is possible
>     to preclude yourself from getting columns if you 'fetch' other
>     columns. If you don't invoke these methods, Accumulo will return you
>     all columns.
>
>     Perhaps you can narrow down your problem using a range for the whole
>     row and then try more restricted ranges.
>
>
>     On 7/17/14, 11:59 AM, Ryan wrote:
>
>         Thanks, that's much simpler. I looked into the API docs for the Key
>         class and found a way to get it down to just: scan.setRange(new
>         Range(new Key(entityUID, startTime), new Key(entityUID, endTime)));
>
>         Unfortunately, that doesn't return any results. Is the scan
>         inclusive?
>         Is it not including the byte array values that is messing it up?
>         I know
>         the problem isn't with the connection because scanning the table
>         without
>         any range values from my program works.
>
>
>         On Thu, Jul 17, 2014 at 11:09 AM, Josh Elser
>         <josh.elser@gmail.com <ma...@gmail.com>
>         <mailto:josh.elser@gmail.com <ma...@gmail.com>>> wrote:
>
>              Sure is. Just provide a start Key and end Key.
>
>              scan.setRange(new Range(new Key(singleRowId.getBytes(),
>              startTime.getBytes(), "0".getBytes()), true, new
>              Key(singleRowId.getBytes(), endTime.getBytes(),
>         "1".getBytes()), true);
>
>              The range spans the single row you are interested in, and
>         you can
>              specify up to the column qualifier for the start and end
>         key. If you
>              don't specify the visibility of timestamp, you would end up
>         getting
>              all key-values (cv,timestamp,value) between those two keys.
>
>
>              On 7/17/14, 11:03 AM, Ryan wrote:
>
>                  Hi, I'm learning Accumulo and am attempting to write a Java
>                  client that
>                  scans over an Accumulo table using a single row id and
>         a range
>                  of column
>                  families. Going through the API, the closest thing I've
>         found to
>                  this
>                  feature is the 'bound method:
>
>                  scan.setRange(new Range(entity).bound(new
>                  Column(startTime.getBytes(),
>                  "0".getBytes(), "public".getBytes()), new
>         Column(endTime.getBytes(),
>                  "1".getBytes(), "public".getBytes())));
>
>                  Is there a simpler way to do this without a need to
>         include the
>                  visibility or column qualifier?
>
>                  The API version I'm using is 1.5.1.
>
>
>

Re: Scanning over a range of column families?

Posted by Ryan <fr...@gmail.com>.
Okay, that makes sense. I also tried it with scan.setRange(new Range(new
Key(entityUID), new Key(entityUID))); to the same results. Still no entries
being returned (and hence nothing printing to screen) when I run:

     //iterate through the entries and print them to the console
    for(Entry<Key,Value> entry : scan){
    System.out.println("Printing entries from scan");
    System.out.println(entry.getKey().toString() + " -> " +
entry.getValue().toString());
    }


On Thu, Jul 17, 2014 at 12:11 PM, Josh Elser <jo...@gmail.com> wrote:

> I think by default both Keys provided to a Range are inclusive, when using
> the 4-argument Range constructor, the 2nd and 4th arguments are boolean
> controlling the inclusivity of the 1st and 3rd argument, respectively.
>
> If you invoke any of the fetchColumnFamily/fetchColumns methods, they
> match up with the columns you're scanning over. It is possible to preclude
> yourself from getting columns if you 'fetch' other columns. If you don't
> invoke these methods, Accumulo will return you all columns.
>
> Perhaps you can narrow down your problem using a range for the whole row
> and then try more restricted ranges.
>
>
> On 7/17/14, 11:59 AM, Ryan wrote:
>
>> Thanks, that's much simpler. I looked into the API docs for the Key
>> class and found a way to get it down to just: scan.setRange(new
>> Range(new Key(entityUID, startTime), new Key(entityUID, endTime)));
>>
>> Unfortunately, that doesn't return any results. Is the scan inclusive?
>> Is it not including the byte array values that is messing it up? I know
>> the problem isn't with the connection because scanning the table without
>> any range values from my program works.
>>
>>
>> On Thu, Jul 17, 2014 at 11:09 AM, Josh Elser <josh.elser@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>>     Sure is. Just provide a start Key and end Key.
>>
>>     scan.setRange(new Range(new Key(singleRowId.getBytes(),
>>     startTime.getBytes(), "0".getBytes()), true, new
>>     Key(singleRowId.getBytes(), endTime.getBytes(), "1".getBytes()),
>> true);
>>
>>     The range spans the single row you are interested in, and you can
>>     specify up to the column qualifier for the start and end key. If you
>>     don't specify the visibility of timestamp, you would end up getting
>>     all key-values (cv,timestamp,value) between those two keys.
>>
>>
>>     On 7/17/14, 11:03 AM, Ryan wrote:
>>
>>         Hi, I'm learning Accumulo and am attempting to write a Java
>>         client that
>>         scans over an Accumulo table using a single row id and a range
>>         of column
>>         families. Going through the API, the closest thing I've found to
>>         this
>>         feature is the 'bound method:
>>
>>         scan.setRange(new Range(entity).bound(new
>>         Column(startTime.getBytes(),
>>         "0".getBytes(), "public".getBytes()), new
>> Column(endTime.getBytes(),
>>         "1".getBytes(), "public".getBytes())));
>>
>>         Is there a simpler way to do this without a need to include the
>>         visibility or column qualifier?
>>
>>         The API version I'm using is 1.5.1.
>>
>>
>>

Re: Scanning over a range of column families?

Posted by Josh Elser <jo...@gmail.com>.
I think by default both Keys provided to a Range are inclusive, when 
using the 4-argument Range constructor, the 2nd and 4th arguments are 
boolean controlling the inclusivity of the 1st and 3rd argument, 
respectively.

If you invoke any of the fetchColumnFamily/fetchColumns methods, they 
match up with the columns you're scanning over. It is possible to 
preclude yourself from getting columns if you 'fetch' other columns. If 
you don't invoke these methods, Accumulo will return you all columns.

Perhaps you can narrow down your problem using a range for the whole row 
and then try more restricted ranges.

On 7/17/14, 11:59 AM, Ryan wrote:
> Thanks, that's much simpler. I looked into the API docs for the Key
> class and found a way to get it down to just: scan.setRange(new
> Range(new Key(entityUID, startTime), new Key(entityUID, endTime)));
>
> Unfortunately, that doesn't return any results. Is the scan inclusive?
> Is it not including the byte array values that is messing it up? I know
> the problem isn't with the connection because scanning the table without
> any range values from my program works.
>
>
> On Thu, Jul 17, 2014 at 11:09 AM, Josh Elser <josh.elser@gmail.com
> <ma...@gmail.com>> wrote:
>
>     Sure is. Just provide a start Key and end Key.
>
>     scan.setRange(new Range(new Key(singleRowId.getBytes(),
>     startTime.getBytes(), "0".getBytes()), true, new
>     Key(singleRowId.getBytes(), endTime.getBytes(), "1".getBytes()), true);
>
>     The range spans the single row you are interested in, and you can
>     specify up to the column qualifier for the start and end key. If you
>     don't specify the visibility of timestamp, you would end up getting
>     all key-values (cv,timestamp,value) between those two keys.
>
>
>     On 7/17/14, 11:03 AM, Ryan wrote:
>
>         Hi, I'm learning Accumulo and am attempting to write a Java
>         client that
>         scans over an Accumulo table using a single row id and a range
>         of column
>         families. Going through the API, the closest thing I've found to
>         this
>         feature is the 'bound method:
>
>         scan.setRange(new Range(entity).bound(new
>         Column(startTime.getBytes(),
>         "0".getBytes(), "public".getBytes()), new Column(endTime.getBytes(),
>         "1".getBytes(), "public".getBytes())));
>
>         Is there a simpler way to do this without a need to include the
>         visibility or column qualifier?
>
>         The API version I'm using is 1.5.1.
>
>

Re: Scanning over a range of column families?

Posted by Ryan <fr...@gmail.com>.
Thanks, that's much simpler. I looked into the API docs for the Key class
and found a way to get it down to just: scan.setRange(new Range(new
Key(entityUID, startTime), new Key(entityUID, endTime)));

Unfortunately, that doesn't return any results. Is the scan inclusive? Is
it not including the byte array values that is messing it up? I know the
problem isn't with the connection because scanning the table without any
range values from my program works.


On Thu, Jul 17, 2014 at 11:09 AM, Josh Elser <jo...@gmail.com> wrote:

> Sure is. Just provide a start Key and end Key.
>
> scan.setRange(new Range(new Key(singleRowId.getBytes(),
> startTime.getBytes(), "0".getBytes()), true, new
> Key(singleRowId.getBytes(), endTime.getBytes(), "1".getBytes()), true);
>
> The range spans the single row you are interested in, and you can specify
> up to the column qualifier for the start and end key. If you don't specify
> the visibility of timestamp, you would end up getting all key-values
> (cv,timestamp,value) between those two keys.
>
>
> On 7/17/14, 11:03 AM, Ryan wrote:
>
>> Hi, I'm learning Accumulo and am attempting to write a Java client that
>> scans over an Accumulo table using a single row id and a range of column
>> families. Going through the API, the closest thing I've found to this
>> feature is the 'bound method:
>>
>> scan.setRange(new Range(entity).bound(new Column(startTime.getBytes(),
>> "0".getBytes(), "public".getBytes()), new Column(endTime.getBytes(),
>> "1".getBytes(), "public".getBytes())));
>>
>> Is there a simpler way to do this without a need to include the
>> visibility or column qualifier?
>>
>> The API version I'm using is 1.5.1.
>>
>

Re: Scanning over a range of column families?

Posted by Josh Elser <jo...@gmail.com>.
Sure is. Just provide a start Key and end Key.

scan.setRange(new Range(new Key(singleRowId.getBytes(), 
startTime.getBytes(), "0".getBytes()), true, new 
Key(singleRowId.getBytes(), endTime.getBytes(), "1".getBytes()), true);

The range spans the single row you are interested in, and you can 
specify up to the column qualifier for the start and end key. If you 
don't specify the visibility of timestamp, you would end up getting all 
key-values (cv,timestamp,value) between those two keys.

On 7/17/14, 11:03 AM, Ryan wrote:
> Hi, I'm learning Accumulo and am attempting to write a Java client that
> scans over an Accumulo table using a single row id and a range of column
> families. Going through the API, the closest thing I've found to this
> feature is the 'bound method:
>
> scan.setRange(new Range(entity).bound(new Column(startTime.getBytes(),
> "0".getBytes(), "public".getBytes()), new Column(endTime.getBytes(),
> "1".getBytes(), "public".getBytes())));
>
> Is there a simpler way to do this without a need to include the
> visibility or column qualifier?
>
> The API version I'm using is 1.5.1.