You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Something Something <ma...@gmail.com> on 2011/01/21 08:52:11 UTC

Bytes.toString(value)) returns empty string

I have a column that looks like this under hbase shell:

column=Request:placement, timestamp=1295593730949,
value=specific.ea.tracking.promo.deadspace2


In my code I have something like this...

   byte[] value = result.getValue(Bytes.toBytes("Request"),
Bytes.toBytes("placement"));

LOG.info("Placement in byte: " + value);

LOG.info("Placement in string: " + Bytes.toString(value));


The "Placement in byte" shows some value like this: [B@298488ef

But "Placement in string" returns empty string.

Any reason why?  Please help.  Thanks.

Re: Bytes.toString(value)) returns empty string

Posted by Ryan Rawson <ry...@gmail.com>.
The byte[].toString isnt super helpful, ad JD says it just tells you
the type ([B == array) and the identity (the number).

To get around this in HBase we call Bytes.toString and toStringBinary
_everywhere_.

-ryan

On Fri, Jan 21, 2011 at 6:17 PM, Something Something
<ma...@gmail.com> wrote:
> Sorry.  Dumb user error.  Thanks JD for replying. It's good to know that the
> length is what I should look for in the future.
>
> On Fri, Jan 21, 2011 at 10:49 AM, Jean-Daniel Cryans <jd...@apache.org>wrote:
>
>> > The "Placement in byte" shows some value like this: [B@298488ef
>>
>> This line doesn't prove that there's actual data in that byte array,
>> it only prints the object's address. You can verify there's data by
>> looking at the length.
>>
>> Considering that the value object is empty, it'd suggest that you
>> double-check your code in order to find out why you're not getting
>> that data back if it's supposed to exist.
>>
>> J-D
>>
>> On Thu, Jan 20, 2011 at 11:52 PM, Something Something
>> <ma...@gmail.com> wrote:
>> > I have a column that looks like this under hbase shell:
>> >
>> > column=Request:placement, timestamp=1295593730949,
>> > value=specific.ea.tracking.promo.deadspace2
>> >
>> >
>> > In my code I have something like this...
>> >
>> >   byte[] value = result.getValue(Bytes.toBytes("Request"),
>> > Bytes.toBytes("placement"));
>> >
>> > LOG.info("Placement in byte: " + value);
>> >
>> > LOG.info("Placement in string: " + Bytes.toString(value));
>> >
>> >
>> > The "Placement in byte" shows some value like this: [B@298488ef
>> >
>> > But "Placement in string" returns empty string.
>> >
>> > Any reason why?  Please help.  Thanks.
>> >
>>
>

Re: Bytes.toString(value)) returns empty string

Posted by Something Something <ma...@gmail.com>.
Sorry.  Dumb user error.  Thanks JD for replying. It's good to know that the
length is what I should look for in the future.

On Fri, Jan 21, 2011 at 10:49 AM, Jean-Daniel Cryans <jd...@apache.org>wrote:

> > The "Placement in byte" shows some value like this: [B@298488ef
>
> This line doesn't prove that there's actual data in that byte array,
> it only prints the object's address. You can verify there's data by
> looking at the length.
>
> Considering that the value object is empty, it'd suggest that you
> double-check your code in order to find out why you're not getting
> that data back if it's supposed to exist.
>
> J-D
>
> On Thu, Jan 20, 2011 at 11:52 PM, Something Something
> <ma...@gmail.com> wrote:
> > I have a column that looks like this under hbase shell:
> >
> > column=Request:placement, timestamp=1295593730949,
> > value=specific.ea.tracking.promo.deadspace2
> >
> >
> > In my code I have something like this...
> >
> >   byte[] value = result.getValue(Bytes.toBytes("Request"),
> > Bytes.toBytes("placement"));
> >
> > LOG.info("Placement in byte: " + value);
> >
> > LOG.info("Placement in string: " + Bytes.toString(value));
> >
> >
> > The "Placement in byte" shows some value like this: [B@298488ef
> >
> > But "Placement in string" returns empty string.
> >
> > Any reason why?  Please help.  Thanks.
> >
>

Re: Bytes.toString(value)) returns empty string

Posted by Jean-Daniel Cryans <jd...@apache.org>.
> The "Placement in byte" shows some value like this: [B@298488ef

This line doesn't prove that there's actual data in that byte array,
it only prints the object's address. You can verify there's data by
looking at the length.

Considering that the value object is empty, it'd suggest that you
double-check your code in order to find out why you're not getting
that data back if it's supposed to exist.

J-D

On Thu, Jan 20, 2011 at 11:52 PM, Something Something
<ma...@gmail.com> wrote:
> I have a column that looks like this under hbase shell:
>
> column=Request:placement, timestamp=1295593730949,
> value=specific.ea.tracking.promo.deadspace2
>
>
> In my code I have something like this...
>
>   byte[] value = result.getValue(Bytes.toBytes("Request"),
> Bytes.toBytes("placement"));
>
> LOG.info("Placement in byte: " + value);
>
> LOG.info("Placement in string: " + Bytes.toString(value));
>
>
> The "Placement in byte" shows some value like this: [B@298488ef
>
> But "Placement in string" returns empty string.
>
> Any reason why?  Please help.  Thanks.
>