public final class DataIO extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DataIO.DataInputByteArray
DataInput on top of
byte[] |
static class |
DataIO.DataInputByteBuffer
Wraps
ByteBuffer and provides DataInput |
static interface |
DataIO.DataInputInternal
Give access to internal byte[] or ByteBuffer in DataInput2..
|
static class |
DataIO.DataInputToStream
Wraps
DataInput into InputStream |
static class |
DataIO.DataOutputByteArray
Provides
DataOutput implementation on top of growable byte[]
ByteArrayOutputStream is not used as it requires byte[] copying |
static class |
DataIO.HeartbeatFileLock
File locking mechanism.
|
Modifier and Type | Field and Description |
---|---|
static long |
PACK_LONG_RESULT_MASK |
Modifier and Type | Method and Description |
---|---|
static long |
fillLowBits(int bitCount) |
static byte[] |
fromHexa(String s)
Converts hexadecimal string into binary data
|
static long |
getLong(byte[] buf,
int pos) |
static long |
getSixLong(byte[] buf,
int pos) |
static long |
hash(byte[] buf,
int off,
int len,
long seed)
Calculates XXHash64 from given
byte[] buffer. |
static long |
hash(char[] buf,
int off,
int len,
long seed)
Calculates XXHash64 from given
char[] buffer. |
static int |
intHash(int h) |
static int |
longHash(long h) |
static int |
nextPowTwo(int a) |
static long |
nextPowTwo(long a) |
static void |
packInt(DataOutput out,
int value)
Pack int into an output stream.
|
static void |
packIntBigger(DataOutput out,
int value)
Pack int into an output stream.
|
static void |
packLong(DataOutput out,
long value)
Pack long into output.
|
static void |
packLong(OutputStream out,
long value)
Pack long into output.
|
static int |
packLongBidi(byte[] b,
int pos,
long value)
Pack long into output.
|
static int |
packLongSize(long value)
Calculate how much bytes packed long consumes.
|
static void |
packRecid(DataOutput out,
long value)
Pack RECID into output stream with 3 bit checksum.
|
static long |
parity16Get(long i) |
static long |
parity16Set(long i) |
static long |
parity1Get(long i) |
static long |
parity1Set(long i) |
static long |
parity3Get(long i) |
static long |
parity3Set(long i) |
static long |
parity4Get(long i) |
static long |
parity4Set(long i) |
static void |
putLong(byte[] buf,
int pos,
long v) |
static void |
putSixLong(byte[] buf,
int pos,
long value) |
static void |
readFully(InputStream in,
byte[] data) |
static void |
skipFully(InputStream in,
long length) |
static String |
toHexa(byte[] bb)
Converts binary array into its hexadecimal representation.
|
static int |
unpackInt(DataInput is)
Unpack int value from the input stream.
|
static long |
unpackLong(DataInput in)
Unpack long value from the input stream.
|
static long |
unpackLong(InputStream in)
Unpack long value from the input stream.
|
static long |
unpackLongBidi(byte[] b,
int pos)
Unpack long value.
|
static long |
unpackLongBidiReverse(byte[] bb,
int pos,
int limit) |
static long |
unpackRecid(DataInput in)
Unpack RECID value from the input stream with 3 bit checksum.
|
public static final long PACK_LONG_RESULT_MASK
public static int unpackInt(DataInput is) throws IOException
is
- The input stream.IOException
- in case of IO errorpublic static long unpackLong(DataInput in) throws IOException
in
- The input stream.IOException
- in case of IO errorpublic static long unpackLong(InputStream in) throws IOException
in
- The input stream.IOException
- in case of IO errorpublic static void packLong(DataOutput out, long value) throws IOException
out
- DataOutput to put value intovalue
- to be serialized, must be non-negativeIOException
- in case of IO errorpublic static void packLong(OutputStream out, long value) throws IOException
out
- OutputStream to put value intovalue
- to be serialized, must be non-negativeIOException
- in case of IO errorpublic static int packLongSize(long value)
value
- to calculatepublic static long unpackRecid(DataInput in) throws IOException
in
- The input stream.IOException
- in case of IO errorpublic static void packRecid(DataOutput out, long value) throws IOException
out
- DataOutput to put value intovalue
- to be serialized, must be non-negativeIOException
- in case of IO errorpublic static void packInt(DataOutput out, int value) throws IOException
out
- DataOutput to put value intovalue
- to be serialized, must be non-negativeIOException
- in case of IO errorpublic static void packIntBigger(DataOutput out, int value) throws IOException
packInt(DataOutput, int)
,
but is optimized for values larger than 127. Usually it is recids.out
- DataOutput to put value intovalue
- to be serialized, must be non-negativeIOException
- in case of IO errorpublic static int longHash(long h)
public static int intHash(int h)
public static int packLongBidi(byte[] b, int pos, long value)
b
- byte[] to put value intopos
- array index where value will startvalue
- to be serialized, must be non-negativepublic static long unpackLongBidi(byte[] b, int pos)
result & DataIO.PACK_LONG_RESULT_MASK
to remove size.
This method uses reverse bit flag, which is not compatible with other methods.b
- byte[] to get data frompos
- position to get data frompublic static long unpackLongBidiReverse(byte[] bb, int pos, int limit)
public static long getLong(byte[] buf, int pos)
public static void putLong(byte[] buf, int pos, long v)
public static long getSixLong(byte[] buf, int pos)
public static void putSixLong(byte[] buf, int pos, long value)
public static long nextPowTwo(long a)
public static int nextPowTwo(int a)
public static void readFully(InputStream in, byte[] data) throws IOException
IOException
public static void skipFully(InputStream in, long length) throws IOException
IOException
public static long fillLowBits(int bitCount)
public static long parity1Set(long i)
public static long parity1Get(long i)
public static long parity3Set(long i)
public static long parity3Get(long i)
public static long parity4Set(long i)
public static long parity4Get(long i)
public static long parity16Set(long i)
public static long parity16Get(long i)
public static String toHexa(byte[] bb)
bb
- binary datapublic static byte[] fromHexa(String s)
s
- hexadecimal stringNumberFormatException
- in case of string format errorpublic static long hash(byte[] buf, int off, int len, long seed)
Calculates XXHash64 from given byte[]
buffer.
This code comes from LZ4-Java created by Adrien Grand.
buf
- to calculate hash fromoff
- offset to start calculation fromlen
- length of data to calculate hashseed
- hash seedpublic static long hash(char[] buf, int off, int len, long seed)
Calculates XXHash64 from given char[]
buffer.
This code comes from LZ4-Java created by Adrien Grand.
buf
- to calculate hash fromoff
- offset to start calculation fromlen
- length of data to calculate hashseed
- hash seedCopyright © 2015. All Rights Reserved.