|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.Bytes
public class Bytes
Utility class that handles byte arrays, conversions to/from other types, comparisons, hash code generation, manufacturing keys for HashMaps or HashSets, etc.
Field Summary | |
---|---|
static Comparator<byte[]> |
BYTES_COMPARATOR
Pass this to TreeMaps where byte [] are keys. |
static int |
ESTIMATED_HEAP_TAX
Estimate of size cost to pay beyond payload in jvm for instance of byte []. |
static int |
SIZEOF_DOUBLE
Size of double in bytes |
static int |
SIZEOF_FLOAT
Size of float in bytes |
static int |
SIZEOF_INT
Size of int in bytes |
static int |
SIZEOF_LONG
Size of long in bytes |
Constructor Summary | |
---|---|
Bytes()
|
Method Summary | |
---|---|
static byte[] |
add(byte[] a,
byte[] b)
|
static byte[] |
add(byte[] a,
byte[] b,
byte[] c)
|
static int |
compareTo(byte[] left,
byte[] right)
|
static int |
compareTo(byte[] left,
int leftOffset,
int leftLength,
byte[] right,
int rightOffset,
int rightLength)
|
static boolean |
equals(byte[] left,
byte[] right)
|
static int |
hashCode(byte[] b)
|
static int |
hashCode(byte[] b,
int length)
|
static byte[] |
incrementBytes(byte[] value,
long amount)
Bytewise binary increment/deincrement of long contained in byte array on given amount. |
static Integer |
mapKey(byte[] b)
|
static Integer |
mapKey(byte[] b,
int length)
|
static byte[] |
readByteArray(DataInput in)
|
static byte[][] |
toByteArrays(byte[] column)
|
static byte[][] |
toByteArrays(String column)
|
static byte[][] |
toByteArrays(String[] t)
|
static byte[] |
toBytes(double val)
Convert an double value to a byte array |
static byte[] |
toBytes(float val)
Convert an float value to a byte array |
static byte[] |
toBytes(int val)
Convert an int value to a byte array |
static byte[] |
toBytes(long val)
Convert a long value to a byte array |
static byte[] |
toBytes(String s)
Converts a string to a UTF-8 byte array. |
static double |
toDouble(byte[] bytes)
Converts a byte array to a double value |
static float |
toFloat(byte[] bytes)
Converts a byte array to a float value |
static int |
toInt(byte[] bytes)
Converts a byte array to a long value |
static long |
toLong(byte[] bytes)
Converts a byte array to a long value |
static String |
toString(byte[] b)
|
static void |
writeByteArray(DataOutput out,
byte[] b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SIZEOF_LONG
public static final int SIZEOF_INT
public static final int SIZEOF_FLOAT
public static final int SIZEOF_DOUBLE
public static final int ESTIMATED_HEAP_TAX
public static Comparator<byte[]> BYTES_COMPARATOR
Constructor Detail |
---|
public Bytes()
Method Detail |
---|
public static byte[] readByteArray(DataInput in) throws IOException
in
- Input to read from.
in
IOException
public static void writeByteArray(DataOutput out, byte[] b) throws IOException
out
- b
-
IOException
public static String toString(byte[] b)
b
- Presumed UTF-8 encoded byte array.
b
public static byte[] toBytes(String s)
s
-
public static byte[] toBytes(long val)
val
-
public static long toLong(byte[] bytes)
bytes
-
public static byte[] toBytes(int val)
val
-
public static int toInt(byte[] bytes)
bytes
-
public static byte[] toBytes(float val)
val
-
public static float toFloat(byte[] bytes)
bytes
-
public static byte[] toBytes(double val)
val
-
public static double toDouble(byte[] bytes)
bytes
-
public static int compareTo(byte[] left, byte[] right)
left
- right
-
public static int compareTo(byte[] left, int leftOffset, int leftLength, byte[] right, int rightOffset, int rightLength)
left
- right
- leftOffset
- Where to start comparing in the left bufferrightOffset
- Where to start comparing in the right bufferleftLength
- How much to compare from the left bufferrightLength
- How much to compare from the right buffer
public static boolean equals(byte[] left, byte[] right)
left
- right
-
public static int hashCode(byte[] b)
b
-
WritableComparator.hashBytes(byte[], int)
on the
passed in array. This method is what Text
and
ImmutableBytesWritable
use calculating hash code.public static int hashCode(byte[] b, int length)
b
- length
-
WritableComparator.hashBytes(byte[], int)
on the
passed in array. This method is what Text
and
ImmutableBytesWritable
use calculating hash code.public static Integer mapKey(byte[] b)
b
-
b
as an Integer that can be used as key in
Maps.public static Integer mapKey(byte[] b, int length)
b
- length
-
b
as an Integer that can be used as key in
Maps.public static byte[] add(byte[] a, byte[] b)
a
- b
-
public static byte[] add(byte[] a, byte[] b, byte[] c)
a
- b
- c
-
public static byte[][] toByteArrays(String[] t)
t
-
public static byte[][] toByteArrays(String column)
column
-
column
public static byte[][] toByteArrays(byte[] column)
column
-
column
public static byte[] incrementBytes(byte[] value, long amount) throws IOException
value
- - array of bytes containing long (length <= SIZEOF_LONG)amount
- value will be incremented on (deincremented if negative)
IOException
- - if value.length > SIZEOF_LONG
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |