Allan Macmillan
Allan Macmillan

Reputation: 1491

HBase - getting values back from Bytes.add

Using HBase with Java

If we have

Bytes[] a = Bytes.add(Bytes.toBytes(10), Bytes.toBytes(20));

Is there any way of getting the individual numbers back?

Upvotes: 0

Views: 213

Answers (1)

Lorand Bendig
Lorand Bendig

Reputation: 10650

byte[] lower = Bytes.toBytes(10);
byte[] upper = Bytes.toBytes(20);

byte[] b = Bytes.add(lower,upper);
//get back        
int lowNum = Bytes.toInt(Arrays.copyOfRange(b, 0, lower.length));
int highNum = Bytes.toInt(Arrays.copyOfRange(b, lower.length, b.length));

Upvotes: 1

Related Questions