You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by kitex101 <su...@gmail.com> on 2018/02/18 04:44:19 UTC
How to get string from hbase composite key?
I have key in following format:
byte[] rowKey =
=Bytes.add(Bytes.toBytes("3"),Bytes.toBytes(982222),Bytes.toBytes(1211));
It is stored as byte array.
How to decode it when using java?
Bytes.toString(CellUtil.cloneRow(cell))
results in a�~��
--
Sent from: http://apache-hbase.679495.n3.nabble.com/HBase-User-f4020416.html
Re: How to get string from hbase composite key?
Posted by Ted Yu <yu...@gmail.com>.
I mentioned the method accepting int because of the example in your first
email.
I verified in Eclipse that Bytes.toBytes(982222) would end up in that
method.
I understand in your application data is typed as long. However that is not
shown in your previous example.
On Sat, Feb 17, 2018 at 9:00 PM, Ted Yu <yu...@gmail.com> wrote:
> It seems there are 3 components in the row key.
> Assuming the 2nd and 3rd are integers, you can take a look at the
> following method of Bytes:
>
> public static byte[] toBytes(int val) {
>
> which returns 4 byte long byte array.
> You can use this knowledge to decode each component of the row key.
>
> FYI
>
> On Sat, Feb 17, 2018 at 8:44 PM, kitex101 <su...@gmail.com>
> wrote:
>
>> I have key in following format:
>>
>> byte[] rowKey =
>> =Bytes.add(Bytes.toBytes("3"),Bytes.toBytes(982222),Bytes.toBytes(1211));
>>
>> It is stored as byte array.
>>
>> How to decode it when using java?
>>
>> Bytes.toString(CellUtil.cloneRow(cell))
>>
>> results in a�~��
>>
>>
>>
>>
>> --
>> Sent from: http://apache-hbase.679495.n3.nabble.com/HBase-User-f4020416
>> .html
>>
>
>
Re: How to get string from hbase composite key?
Posted by kitex101 <su...@gmail.com>.
So, it would be like manually getting 4 byte. Actually they are long.
--
Sent from: http://apache-hbase.679495.n3.nabble.com/HBase-User-f4020416.html
Re: How to get string from hbase composite key?
Posted by Ted Yu <yu...@gmail.com>.
It seems there are 3 components in the row key.
Assuming the 2nd and 3rd are integers, you can take a look at the following
method of Bytes:
public static byte[] toBytes(int val) {
which returns 4 byte long byte array.
You can use this knowledge to decode each component of the row key.
FYI
On Sat, Feb 17, 2018 at 8:44 PM, kitex101 <su...@gmail.com> wrote:
> I have key in following format:
>
> byte[] rowKey =
> =Bytes.add(Bytes.toBytes("3"),Bytes.toBytes(982222),Bytes.toBytes(1211));
>
> It is stored as byte array.
>
> How to decode it when using java?
>
> Bytes.toString(CellUtil.cloneRow(cell))
>
> results in a�~��
>
>
>
>
> --
> Sent from: http://apache-hbase.679495.n3.nabble.com/HBase-User-
> f4020416.html
>