Details
-
Improvement
-
Status: Open
-
Blocker
-
Resolution: Unresolved
-
None
-
None
-
None
Description
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