public class ReadWriteForEncodingUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
getIntMaxBitWidth(List<Integer> list)
check all number in a int list and find max bit width.
|
static int |
getLongMaxBitWidth(List<Long> list)
check all number in a long list and find max bit width.
|
static byte[] |
getUnsignedVarInt(int value)
transform an int var to byte[] format.
|
static int |
readIntLittleEndianPaddedOnBitWidth(ByteBuffer buffer,
int bitWidth)
read integer value using special bit from input stream.
|
static long |
readLongLittleEndianPaddedOnBitWidth(ByteBuffer buffer,
int bitWidth)
read long value using special bit from input stream.
|
static int |
readUnsignedVarInt(ByteBuffer buffer)
read an unsigned var int in stream and transform it to int format.
|
static int |
readUnsignedVarInt(InputStream in)
read an unsigned var int in stream and transform it to int format.
|
static int |
readVarInt(ByteBuffer buffer) |
static int |
readVarInt(InputStream in) |
static int |
uVarIntSize(int value)
Returns the encoding size in bytes of its input value.
|
static int |
varIntSize(int value)
Returns the encoding size in bytes of its input value.
|
static void |
writeIntLittleEndianPaddedOnBitWidth(int value,
OutputStream out,
int bitWidth)
write integer value using special bit to output stream.
|
static void |
writeLongLittleEndianPaddedOnBitWidth(long value,
OutputStream out,
int bitWidth)
write long value using special bit to output stream.
|
static int |
writeUnsignedVarInt(int value,
ByteArrayOutputStream out)
write a value to stream using unsigned var int format.
|
static int |
writeUnsignedVarInt(int value,
ByteBuffer buffer)
write a value to stream using unsigned var int format.
|
static int |
writeUnsignedVarInt(int value,
OutputStream out) |
static int |
writeVarInt(int value,
ByteArrayOutputStream out) |
static int |
writeVarInt(int value,
ByteBuffer buffer) |
static int |
writeVarInt(int value,
OutputStream out) |
public static int getIntMaxBitWidth(List<Integer> list)
list - input listpublic static int getLongMaxBitWidth(List<Long> list)
list - input listpublic static byte[] getUnsignedVarInt(int value)
public static int readUnsignedVarInt(InputStream in) throws IOException
in - stream to read an unsigned var intIOException - exception in IOpublic static int readVarInt(InputStream in) throws IOException
IOExceptionpublic static int readUnsignedVarInt(ByteBuffer buffer)
buffer - stream to read an unsigned var intpublic static int readVarInt(ByteBuffer buffer)
public static int writeUnsignedVarInt(int value,
ByteArrayOutputStream out)
value - value to write into streamout - output streampublic static int writeVarInt(int value,
ByteArrayOutputStream out)
public static int writeUnsignedVarInt(int value,
OutputStream out)
throws IOException
IOExceptionpublic static int writeVarInt(int value,
OutputStream out)
throws IOException
IOExceptionpublic static int writeUnsignedVarInt(int value,
ByteBuffer buffer)
value - value to write into streambuffer - where to store the result. buffer.remaining() needs to >= 32. Notice: (1) this
function does not check buffer's remaining(). (2) the position will be updated.IOException - exception in IOpublic static int writeVarInt(int value,
ByteBuffer buffer)
public static int varIntSize(int value)
value - the integer to be measuredpublic static int uVarIntSize(int value)
value - the unsigned integer to be measuredpublic static void writeIntLittleEndianPaddedOnBitWidth(int value,
OutputStream out,
int bitWidth)
throws IOException
value - value to write to streamout - output streambitWidth - bit lengthIOException - exception in IOpublic static void writeLongLittleEndianPaddedOnBitWidth(long value,
OutputStream out,
int bitWidth)
throws IOException
value - value to write to streamout - output streambitWidth - bit lengthIOException - exception in IOpublic static int readIntLittleEndianPaddedOnBitWidth(ByteBuffer buffer, int bitWidth) throws IOException
buffer - byte bufferbitWidth - bit lengthIOException - exception in IOpublic static long readLongLittleEndianPaddedOnBitWidth(ByteBuffer buffer, int bitWidth) throws IOException
buffer - byte bufferbitWidth - bit lengthIOException - exception in IOCopyright © 2022 The Apache Software Foundation. All rights reserved.