|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.gora.util.ByteUtils
public class ByteUtils
Utility class that handles byte arrays, conversions to/from other types.
Field Summary | |
---|---|
static int |
SIZEOF_BOOLEAN
Size of boolean in bytes |
static int |
SIZEOF_BYTE
Size of byte in bytes |
static int |
SIZEOF_CHAR
Size of char in bytes |
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 |
static int |
SIZEOF_SHORT
Size of short in bytes |
Constructor Summary | |
---|---|
ByteUtils()
|
Method Summary | |
---|---|
static int |
bytesToVint(byte[] buffer)
|
static long |
bytesToVlong(byte[] buffer)
|
static int |
compareTo(byte[] left,
byte[] right)
|
static int |
compareTo(byte[] b1,
int s1,
int l1,
byte[] b2,
int s2,
int l2)
|
static boolean |
equals(byte[] left,
byte[] right)
|
static Object |
fromBytes(byte[] val,
org.apache.avro.Schema schema,
PersistentDatumReader<?> datumReader,
Object object)
|
static int |
putByte(byte[] bytes,
int offset,
byte b)
Write a single byte out to the specified byte array position. |
static int |
putBytes(byte[] tgtBytes,
int tgtOffset,
byte[] srcBytes,
int srcOffset,
int srcLength)
Put bytes at the specified byte array position. |
static long |
readVLong(byte[] buffer,
int offset)
Reads a zero-compressed encoded long from input stream and returns it. |
static boolean |
toBoolean(byte[] b)
|
static byte[] |
toBytes(boolean b)
Convert a boolean to a byte array. |
static byte[] |
toBytes(ByteBuffer bb)
Returns a new byte array, copied from the passed ByteBuffer. |
static byte[] |
toBytes(char val)
Convert a char value to a byte array |
static byte[] |
toBytes(double d)
|
static byte[] |
toBytes(float f)
|
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(Object o,
org.apache.avro.Schema schema,
PersistentDatumWriter<?> datumWriter)
|
static byte[] |
toBytes(short val)
Convert a short value to a byte array |
static byte[] |
toBytes(String s)
Converts a string to a UTF-8 byte array. |
static char |
toChar(byte[] bytes)
Converts a byte array to a char value |
static char |
toChar(byte[] bytes,
int offset)
Converts a byte array to a char value |
static char |
toChar(byte[] bytes,
int offset,
int length)
Converts a byte array to a char value |
static char[] |
toChars(byte[] bytes)
Converts a byte array to a char array value |
static char[] |
toChars(byte[] bytes,
int offset)
Converts a byte array to a char array value |
static char[] |
toChars(byte[] bytes,
int offset,
int length)
Converts a byte array to a char array value |
static double |
toDouble(byte[] bytes)
|
static double |
toDouble(byte[] bytes,
int offset)
|
static float |
toFloat(byte[] bytes)
Presumes float encoded as IEEE 754 floating-point "single format" |
static float |
toFloat(byte[] bytes,
int offset)
Presumes float encoded as IEEE 754 floating-point "single format" |
static int |
toInt(byte[] bytes)
Converts a byte array to an int value |
static int |
toInt(byte[] bytes,
int offset)
Converts a byte array to an int value |
static int |
toInt(byte[] bytes,
int offset,
int length)
Converts a byte array to an int value |
static long |
toLong(byte[] bytes)
Converts a byte array to a long value |
static long |
toLong(byte[] bytes,
int offset)
Converts a byte array to a long value |
static long |
toLong(byte[] bytes,
int offset,
int length)
Converts a byte array to a long value |
static short |
toShort(byte[] bytes)
Converts a byte array to a short value |
static short |
toShort(byte[] bytes,
int offset)
Converts a byte array to a short value |
static short |
toShort(byte[] bytes,
int offset,
int length)
Converts a byte array to a short value |
static String |
toString(byte[] b)
|
static String |
toString(byte[] b,
int off,
int len)
|
static String |
toString(byte[] b1,
String sep,
byte[] b2)
|
static byte[] |
vintToBytes(long vint)
|
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_BOOLEAN
public static final int SIZEOF_BYTE
public static final int SIZEOF_CHAR
public static final int SIZEOF_DOUBLE
public static final int SIZEOF_FLOAT
public static final int SIZEOF_INT
public static final int SIZEOF_LONG
public static final int SIZEOF_SHORT
Constructor Detail |
---|
public ByteUtils()
Method Detail |
---|
public static int putBytes(byte[] tgtBytes, int tgtOffset, byte[] srcBytes, int srcOffset, int srcLength)
tgtBytes
- the byte arraytgtOffset
- position in the arraysrcBytes
- byte to write outsrcOffset
- srcLength
-
public static int putByte(byte[] bytes, int offset, byte b)
bytes
- the byte arrayoffset
- position in the arrayb
- byte to write out
public static byte[] toBytes(ByteBuffer bb)
bb
- A ByteBuffer
public static String toString(byte[] b)
b
- Presumed UTF-8 encoded byte array.
b
public static String toString(byte[] b1, String sep, byte[] b2)
public static String toString(byte[] b, int off, int len)
b
- Presumed UTF-8 encoded byte array.off
- len
-
b
public static byte[] toBytes(String s)
s
-
public static byte[] toBytes(boolean b)
b
-
b
encoded in a byte array.public static boolean toBoolean(byte[] b)
b
-
public static byte[] toBytes(long val)
val
-
public static long toLong(byte[] bytes)
bytes
-
public static long toLong(byte[] bytes, int offset)
bytes
- offset
-
public static long toLong(byte[] bytes, int offset, int length)
bytes
- offset
- length
-
public static float toFloat(byte[] bytes)
bytes
-
public static float toFloat(byte[] bytes, int offset)
bytes
- offset
-
public static byte[] toBytes(float f)
f
-
public static double toDouble(byte[] bytes)
bytes
-
public static double toDouble(byte[] bytes, int offset)
bytes
- offset
-
public static byte[] toBytes(double d)
d
-
public static byte[] toBytes(int val)
val
-
public static int toInt(byte[] bytes)
bytes
-
public static int toInt(byte[] bytes, int offset)
bytes
- offset
-
public static int toInt(byte[] bytes, int offset, int length)
bytes
- offset
- length
-
public static byte[] toBytes(short val)
val
-
public static short toShort(byte[] bytes)
bytes
-
public static short toShort(byte[] bytes, int offset)
bytes
- offset
-
public static short toShort(byte[] bytes, int offset, int length)
bytes
- offset
- length
-
public static byte[] toBytes(char val)
val
-
public static char toChar(byte[] bytes)
bytes
-
public static char toChar(byte[] bytes, int offset)
bytes
- offset
-
public static char toChar(byte[] bytes, int offset, int length)
bytes
- offset
- length
-
public static char[] toChars(byte[] bytes)
bytes
-
public static char[] toChars(byte[] bytes, int offset)
bytes
- offset
-
public static char[] toChars(byte[] bytes, int offset, int length)
bytes
- offset
- length
-
public static byte[] vintToBytes(long vint)
vint
- Integer to make a vint of.
public static long bytesToVlong(byte[] buffer)
buffer
-
public static int bytesToVint(byte[] buffer)
buffer
-
public static long readVLong(byte[] buffer, int offset) throws IOException
buffer
- Binary arrayoffset
- Offset into array at which vint begins.
IOException
public static int compareTo(byte[] left, byte[] right)
left
- right
-
public static int compareTo(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
b1
- b2
- s1
- Where to start comparing in the left buffers2
- Where to start comparing in the right bufferl1
- How much to compare from the left bufferl2
- How much to compare from the right buffer
public static boolean equals(byte[] left, byte[] right)
left
- right
-
public static Object fromBytes(byte[] val, org.apache.avro.Schema schema, PersistentDatumReader<?> datumReader, Object object) throws IOException
IOException
public static byte[] toBytes(Object o, org.apache.avro.Schema schema, PersistentDatumWriter<?> datumWriter) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |