@Deprecated @InterfaceAudience.Public public final class ByteBufferUtils extends Object
Modifier and Type | Class and Description |
---|---|
private static interface |
ByteBufferUtils.ByteVisitor
Deprecated.
|
(package private) static class |
ByteBufferUtils.Comparer
Deprecated.
|
(package private) static class |
ByteBufferUtils.ComparerHolder
Deprecated.
|
(package private) static class |
ByteBufferUtils.Converter
Deprecated.
|
(package private) static class |
ByteBufferUtils.ConverterHolder
Deprecated.
|
Modifier and Type | Field and Description |
---|---|
static int |
NEXT_BIT_MASK
Deprecated.
|
static int |
NEXT_BIT_SHIFT
Deprecated.
|
(package private) static boolean |
UNSAFE_AVAIL
Deprecated.
|
static boolean |
UNSAFE_UNALIGNED
Deprecated.
|
static int |
VALUE_MASK
Deprecated.
|
Modifier | Constructor and Description |
---|---|
private |
ByteBufferUtils()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
arePartsEqual(ByteBuffer buffer,
int offsetLeft,
int lengthLeft,
int offsetRight,
int lengthRight)
Deprecated.
Check whether two parts in the same buffer are equal.
|
static int |
compareTo(byte[] buf1,
int o1,
int l1,
ByteBuffer buf2,
int o2,
int l2)
Deprecated.
|
static int |
compareTo(ByteBuffer buf1,
int o1,
int l1,
byte[] buf2,
int o2,
int l2)
Deprecated.
|
static int |
compareTo(ByteBuffer buf1,
int o1,
int l1,
ByteBuffer buf2,
int o2,
int l2)
Deprecated.
|
(package private) static int |
compareToUnsafe(Object obj1,
long o1,
int l1,
Object obj2,
long o2,
int l2)
Deprecated.
|
static void |
copyBufferToStream(DataOutput out,
ByteBuffer in,
int offset,
int length)
Deprecated.
Copy data from a buffer to an output stream.
|
static void |
copyBufferToStream(OutputStream out,
ByteBuffer in,
int offset,
int length)
Deprecated.
Copy data from a buffer to an output stream.
|
static void |
copyFromArrayToBuffer(ByteBuffer out,
byte[] in,
int inOffset,
int length)
Deprecated.
Copies the bytes from given array's offset to length part into the given buffer.
|
static void |
copyFromArrayToBuffer(ByteBuffer out,
int outOffset,
byte[] in,
int inOffset,
int length)
Deprecated.
Copies bytes from given array's offset to length part into the given buffer.
|
static void |
copyFromBufferToArray(byte[] out,
ByteBuffer in,
int sourceOffset,
int destinationOffset,
int length)
Deprecated.
Copies specified number of bytes from given offset of 'in' ByteBuffer to
the array.
|
static void |
copyFromBufferToBuffer(ByteBuffer in,
ByteBuffer out)
Deprecated.
Copy one buffer's whole data to another.
|
static void |
copyFromBufferToBuffer(ByteBuffer in,
ByteBuffer out,
int sourceOffset,
int length)
Deprecated.
Copy from one buffer to another from given offset.
|
static void |
copyFromBufferToBuffer(ByteBuffer in,
ByteBuffer out,
int sourceOffset,
int destinationOffset,
int length)
Deprecated.
Copy from one buffer to another from given offset.
|
static void |
copyFromStreamToBuffer(ByteBuffer out,
DataInputStream in,
int length)
Deprecated.
Copy the given number of bytes from the given stream and put it at the
current position of the given buffer, updating the position in the buffer.
|
static byte[] |
copyOfRange(ByteBuffer original,
int from,
int to)
Deprecated.
Similar to
Arrays.copyOfRange(byte[], int, int) |
static ByteBuffer |
drainInputStreamToBuffer(InputStream is)
Deprecated.
Copy from the InputStream to a new heap ByteBuffer until the InputStream is exhausted.
|
static boolean |
equals(ByteBuffer buf1,
int o1,
int l1,
byte[] buf2,
int o2,
int l2)
Deprecated.
|
static boolean |
equals(ByteBuffer buf1,
int o1,
int l1,
ByteBuffer buf2,
int o2,
int l2)
Deprecated.
|
static void |
extendLimit(ByteBuffer buffer,
int numBytes)
Deprecated.
|
static int |
findCommonPrefix(byte[] left,
int leftOffset,
int leftLength,
byte[] right,
int rightOffset,
int rightLength)
Deprecated.
Find length of common prefix in two arrays.
|
static int |
findCommonPrefix(ByteBuffer left,
int leftOffset,
int leftLength,
ByteBuffer right,
int rightOffset,
int rightLength)
Deprecated.
Find length of common prefix in two arrays.
|
static int |
findCommonPrefix(ByteBuffer buffer,
int offsetLeft,
int offsetRight,
int limit)
Deprecated.
Find length of common prefix of two parts in the buffer
|
static int |
hashCode(ByteBuffer buf,
int offset,
int length)
Deprecated.
|
static int |
intFitsIn(int value)
Deprecated.
Check how many bytes is required to store value.
|
static int |
longFitsIn(long value)
Deprecated.
Check how many bytes are required to store value.
|
static void |
moveBufferToStream(OutputStream out,
ByteBuffer in,
int length)
Deprecated.
Copy the data to the output stream and update position in buffer.
|
static int |
putAsShort(ByteBuffer buf,
int index,
int val)
Deprecated.
|
static int |
putByte(ByteBuffer buffer,
int offset,
byte b)
Deprecated.
|
static int |
putCompressedInt(OutputStream out,
int value)
Deprecated.
Put in buffer integer using 7 bit encoding.
|
static void |
putInt(ByteBuffer buffer,
int val)
Deprecated.
Put an int value out to the given ByteBuffer's current position in big-endian format.
|
static int |
putInt(ByteBuffer buffer,
int index,
int val)
Deprecated.
|
static void |
putInt(OutputStream out,
int value)
Deprecated.
Put in output stream 32 bit integer (Big Endian byte order).
|
static int |
putLong(ByteBuffer buffer,
int index,
long val)
Deprecated.
|
static void |
putLong(ByteBuffer buffer,
long val)
Deprecated.
Put a long value out to the given ByteBuffer's current position in big-endian format.
|
static int |
putLong(OutputStream out,
long value,
int fitInBytes)
Deprecated.
|
static int |
putShort(ByteBuffer buffer,
int index,
short val)
Deprecated.
|
static void |
putShort(ByteBuffer buffer,
short val)
Deprecated.
Put a short value out to the given ByteBuffer's current position in big-endian format.
|
static int |
readAsInt(ByteBuffer buf,
int offset,
int length)
Deprecated.
Converts a ByteBuffer to an int value
|
static int |
readCompressedInt(ByteBuffer buffer)
Deprecated.
Read integer from buffer coded in 7 bits and increment position.
|
static int |
readCompressedInt(InputStream input)
Deprecated.
Read integer from stream coded in 7 bits and increment position.
|
static long |
readLong(ByteBuffer in,
int fitInBytes)
Deprecated.
Read long which was written to fitInBytes bytes and increment position.
|
static long |
readLong(InputStream in,
int fitInBytes)
Deprecated.
Read long which was written to fitInBytes bytes and increment position.
|
static long |
readVLong(ByteBuff in)
Deprecated.
Similar to
WritableUtils.readVLong(java.io.DataInput) but reads from a
ByteBuff . |
static long |
readVLong(ByteBuffer in)
Deprecated.
Similar to
WritableUtils.readVLong(DataInput) but reads from a ByteBuffer . |
private static long |
readVLong(ByteBufferUtils.ByteVisitor visitor)
Deprecated.
|
static void |
skip(ByteBuffer buffer,
int length)
Deprecated.
Increment position in buffer.
|
static BigDecimal |
toBigDecimal(ByteBuffer buffer,
int offset,
int length)
Deprecated.
Reads a BigDecimal value at the given buffer's offset.
|
static byte |
toByte(ByteBuffer buffer,
int offset)
Deprecated.
|
static byte[] |
toBytes(ByteBuffer buffer,
int startPosition)
Deprecated.
Copy the bytes from position to limit into a new byte[] of the exact length and sets the
position and limit back to their original values (though not thread safe).
|
static byte[] |
toBytes(ByteBuffer buffer,
int offset,
int length)
Deprecated.
Copy the given number of bytes from specified offset into a new byte[]
|
static double |
toDouble(ByteBuffer buffer,
int offset)
Deprecated.
Reads a double value at the given buffer's offset.
|
static int |
toInt(ByteBuffer buffer)
Deprecated.
Reads an int value at the given buffer's current position.
|
static int |
toInt(ByteBuffer buffer,
int offset)
Deprecated.
Reads an int value at the given buffer's offset.
|
static long |
toLong(ByteBuffer buffer,
int offset)
Deprecated.
Reads a long value at the given buffer's offset.
|
static short |
toShort(ByteBuffer buffer,
int offset)
Deprecated.
Reads a short value at the given buffer's offset.
|
static String |
toStringBinary(ByteBuffer b)
Deprecated.
|
static String |
toStringBinary(ByteBuffer b,
int off,
int len)
Deprecated.
|
static void |
writeVLong(ByteBuffer out,
long i)
Deprecated.
Similar to
WritableUtils.writeVLong(java.io.DataOutput, long) ,
but writes to a ByteBuffer . |
public static final int VALUE_MASK
public static final int NEXT_BIT_SHIFT
public static final int NEXT_BIT_MASK
static final boolean UNSAFE_AVAIL
public static final boolean UNSAFE_UNALIGNED
private ByteBufferUtils()
public static void writeVLong(ByteBuffer out, long i)
WritableUtils.writeVLong(java.io.DataOutput, long)
,
but writes to a ByteBuffer
.private static long readVLong(ByteBufferUtils.ByteVisitor visitor)
public static long readVLong(ByteBuffer in)
WritableUtils.readVLong(DataInput)
but reads from a ByteBuffer
.public static long readVLong(ByteBuff in)
WritableUtils.readVLong(java.io.DataInput)
but reads from a
ByteBuff
.public static int putCompressedInt(OutputStream out, int value) throws IOException
value
- Int to be compressed.out
- Where to put compressed dataIOException
- on stream errorpublic static void putInt(OutputStream out, int value) throws IOException
out
- Where to put integer.value
- Value of integer.IOException
- On stream error.public static byte toByte(ByteBuffer buffer, int offset)
public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length) throws IOException
out
- the stream to write bytes toin
- the buffer to read bytes fromlength
- the number of bytes to copyIOException
public static void copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) throws IOException
out
- the stream to write bytes toin
- the buffer to read bytes fromoffset
- the offset in the buffer (from the buffer's array offset)
to start copying bytes fromlength
- the number of bytes to copyIOException
public static void copyBufferToStream(DataOutput out, ByteBuffer in, int offset, int length) throws IOException
out
- the output stream to write bytes toin
- the buffer to read bytes fromoffset
- the offset in the buffer (from the buffer's array offset)
to start copying bytes fromlength
- the number of bytes to copyIOException
public static int putLong(OutputStream out, long value, int fitInBytes) throws IOException
IOException
public static int putByte(ByteBuffer buffer, int offset, byte b)
public static int longFitsIn(long value)
value
- Value which size will be tested.public static int intFitsIn(int value)
value
- Value which size will be tested.public static int readCompressedInt(InputStream input) throws IOException
IOException
public static int readCompressedInt(ByteBuffer buffer)
public static long readLong(InputStream in, int fitInBytes) throws IOException
fitInBytes
- In how many bytes given long is stored.IOException
public static long readLong(ByteBuffer in, int fitInBytes)
fitInBytes
- In how many bytes given long is stored.public static void copyFromStreamToBuffer(ByteBuffer out, DataInputStream in, int length) throws IOException
out
- the buffer to write data toin
- the stream to read data fromlength
- the number of bytes to read/writeIOException
public static ByteBuffer drainInputStreamToBuffer(InputStream is) throws IOException
IOException
public static void copyFromBufferToBuffer(ByteBuffer in, ByteBuffer out)
out
and also change the position maker
for in
.in
- source bufferout
- destination bufferpublic static void copyFromBufferToBuffer(ByteBuffer in, ByteBuffer out, int sourceOffset, int destinationOffset, int length)
in
- out
- sourceOffset
- destinationOffset
- length
- public static void copyFromBufferToBuffer(ByteBuffer in, ByteBuffer out, int sourceOffset, int length)
Note : This will advance the position marker of out
but not change the position maker
for in
in
- source bufferout
- destination buffersourceOffset
- offset in the source bufferlength
- how many bytes to copypublic static int findCommonPrefix(ByteBuffer buffer, int offsetLeft, int offsetRight, int limit)
buffer
- Where parts are located.offsetLeft
- Offset of the first part.offsetRight
- Offset of the second part.limit
- Maximal length of common prefix.public static int findCommonPrefix(byte[] left, int leftOffset, int leftLength, byte[] right, int rightOffset, int rightLength)
left
- Array to be compared.leftOffset
- Offset in left array.leftLength
- Length of left array.right
- Array to be compared.rightOffset
- Offset in right array.rightLength
- Length of right array.public static int findCommonPrefix(ByteBuffer left, int leftOffset, int leftLength, ByteBuffer right, int rightOffset, int rightLength)
left
- ByteBuffer to be compared.leftOffset
- Offset in left ByteBuffer.leftLength
- Length of left ByteBuffer.right
- ByteBuffer to be compared.rightOffset
- Offset in right ByteBuffer.rightLength
- Length of right ByteBuffer.public static boolean arePartsEqual(ByteBuffer buffer, int offsetLeft, int lengthLeft, int offsetRight, int lengthRight)
buffer
- In which buffer there are partsoffsetLeft
- Beginning of first part.lengthLeft
- Length of the first part.offsetRight
- Beginning of the second part.lengthRight
- Length of the second part.public static void skip(ByteBuffer buffer, int length)
buffer
- In this buffer.length
- By that many bytes.public static void extendLimit(ByteBuffer buffer, int numBytes)
public static byte[] toBytes(ByteBuffer buffer, int startPosition)
buffer
- copy from herestartPosition
- put buffer.get(startPosition) into byte[0]public static byte[] toBytes(ByteBuffer buffer, int offset, int length)
buffer
- offset
- length
- public static boolean equals(ByteBuffer buf1, int o1, int l1, ByteBuffer buf2, int o2, int l2)
public static int hashCode(ByteBuffer buf, int offset, int length)
buf
- ByteBuffer to hashoffset
- offset to start fromlength
- length to hashpublic static int compareTo(ByteBuffer buf1, int o1, int l1, ByteBuffer buf2, int o2, int l2)
public static boolean equals(ByteBuffer buf1, int o1, int l1, byte[] buf2, int o2, int l2)
public static int compareTo(byte[] buf1, int o1, int l1, ByteBuffer buf2, int o2, int l2)
public static int compareTo(ByteBuffer buf1, int o1, int l1, byte[] buf2, int o2, int l2)
static int compareToUnsafe(Object obj1, long o1, int l1, Object obj2, long o2, int l2)
public static short toShort(ByteBuffer buffer, int offset)
buffer
- offset
- public static int toInt(ByteBuffer buffer)
public static int toInt(ByteBuffer buffer, int offset)
buffer
- offset
- public static int readAsInt(ByteBuffer buf, int offset, int length)
buf
- The ByteBufferoffset
- Offset to int valuelength
- Number of bytes used to store the int value.IllegalArgumentException
- if there's not enough bytes left in the buffer after the given offsetpublic static long toLong(ByteBuffer buffer, int offset)
buffer
- offset
- public static void putInt(ByteBuffer buffer, int val)
buffer
- the ByteBuffer to write toval
- int to write outpublic static int putInt(ByteBuffer buffer, int index, int val)
public static double toDouble(ByteBuffer buffer, int offset)
buffer
- offset
- offset where double ispublic static BigDecimal toBigDecimal(ByteBuffer buffer, int offset, int length)
buffer
- offset
- public static void putShort(ByteBuffer buffer, short val)
buffer
- the ByteBuffer to write toval
- short to write outpublic static int putShort(ByteBuffer buffer, int index, short val)
public static int putAsShort(ByteBuffer buf, int index, int val)
public static void putLong(ByteBuffer buffer, long val)
buffer
- the ByteBuffer to write toval
- long to write outpublic static int putLong(ByteBuffer buffer, int index, long val)
public static void copyFromArrayToBuffer(ByteBuffer out, byte[] in, int inOffset, int length)
out
- in
- inOffset
- length
- public static void copyFromArrayToBuffer(ByteBuffer out, int outOffset, byte[] in, int inOffset, int length)
out
- in
- inOffset
- length
- public static void copyFromBufferToArray(byte[] out, ByteBuffer in, int sourceOffset, int destinationOffset, int length)
out
- in
- sourceOffset
- destinationOffset
- length
- public static byte[] copyOfRange(ByteBuffer original, int from, int to)
Arrays.copyOfRange(byte[], int, int)
original
- the buffer from which the copy has to happenfrom
- the starting indexto
- the ending indexpublic static String toStringBinary(ByteBuffer b, int off, int len)
public static String toStringBinary(ByteBuffer b)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.