You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Douglas Campbell <de...@yahoo.com> on 2010/08/10 21:05:02 UTC
hbase shell snippet for "get" ing records with binary keys
If I have a record whose key is binary i.e. when you do a scan and you see
something like
\xFF\xD3\xEF\xB4\xEA
as the key
How to pass it back into hbase shell to do a get?
I tried importing Bytes class but Bytes.toBytes(above string) yields a java
array which can't be used as an arg to get.
-Doug
Re: hbase shell snippet for "get" ing records with binary keys
Posted by Andrey Stepachev <oc...@gmail.com>.
Sorry, function should be
def fetch(table, id, args = {})
get table, String.from_java_bytes(Bytes.toBytes(id)), args
end
Re: hbase shell snippet for "get" ing records with binary keys
Posted by Andrey Stepachev <oc...@gmail.com>.
And of course, you can use the Power of Ruby:
type in shell:
def fetch(table, id, args = {})
get table, String.from_java_bytes(Writables.getBytes(id)), args
end
then you can use
> fetch 'my.table', 1234, { other get parameters }
2010/8/10 Douglas Campbell <de...@yahoo.com>:
> If I have a record whose key is binary i.e. when you do a scan and you see
> something like
>
> \xFF\xD3\xEF\xB4\xEA
>
> as the key
>
> How to pass it back into hbase shell to do a get?
>
> I tried importing Bytes class but Bytes.toBytes(above string) yields a java
> array which can't be used as an arg to get.
>
> -Doug
>
>
>
>
>
Re: hbase shell snippet for "get" ing records with binary keys
Posted by Stack <st...@duboce.net>.
hbase> get TABLENAME, "\xFF\xD3\xEF\xB4\xEA"
... should work. Use double-quotes rather than single. (j)irb should
do the right thing (tm) with it.
St.Ack
On Tue, Aug 10, 2010 at 12:05 PM, Douglas Campbell <de...@yahoo.com> wrote:
> If I have a record whose key is binary i.e. when you do a scan and you see
> something like
>
> \xFF\xD3\xEF\xB4\xEA
>
> as the key
>
> How to pass it back into hbase shell to do a get?
>
> I tried importing Bytes class but Bytes.toBytes(above string) yields a java
> array which can't be used as an arg to get.
>
> -Doug
>
>
>
>
>