larry chen created HBASE-25708:
----------------------------------
Summary: Bytes.toInt(byte[] bytes)-why set default offset as zero
Key: HBASE-25708
URL: https://issues.apache.org/jira/browse/HBASE-25708
Project: HBase
Issue Type: Improvement
Components: community
Reporter: larry chen
As we know, when using Bytes.tobytes(int), the method convert the int value to
byte-array with big endian.
So, when we try to extract the right int-value from byte-array, we use method
'Bytes.toInt(byte[] bytes)', and int the method, it sets the offset as zero.
it shows like this
/**
* Converts a byte array to an int value
* @param bytes byte array
* @return the int value
*/
public static int toInt(byte[] bytes) {
return toInt(bytes, 0, SIZEOF_INT);
}
My question is :
why don't we set the offset as (bytes.length - SIZEOF_INT)?
Recently, we have long-value stored in hbase, as we try to extract, we decode
the byte-array as int-value, it leads some incorrect-value like 0.
The usage of decoding-int-value from long-value-byte-array is wrong, I'm just
curious about the start point of setting offset as 0
--
This message was sent by Atlassian Jira
(v8.3.4#803005)