Package org.apache.arrow.vector.util
Class ReusableByteArray
java.lang.Object
org.apache.arrow.vector.util.ReusableByteArray
- All Implemented Interfaces:
ReusableBuffer<byte[]>
- Direct Known Subclasses:
Text
A wrapper around byte arrays for repeated writing.
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[]
protected static final byte[]
protected int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
byte[]
Get the buffer backing this ReusableBuffer.long
Get the number of bytes in the byte array.int
hashCode()
void
set
(byte[] srcBytes, long start, long len) void
Set the buffer to the contents of the given ArrowBuf.protected void
setCapacity
(int len, boolean keepData) Sets the capacity of this object to at leastlen
bytes.toString()
-
Field Details
-
EMPTY_BYTES
protected static final byte[] EMPTY_BYTES -
bytes
protected byte[] bytes -
length
protected int length
-
-
Constructor Details
-
ReusableByteArray
public ReusableByteArray() -
ReusableByteArray
public ReusableByteArray(byte[] data)
-
-
Method Details
-
getLength
public long getLength()Get the number of bytes in the byte array.- Specified by:
getLength
in interfaceReusableBuffer<byte[]>
- Returns:
- the number of bytes in the byte array
-
getBuffer
public byte[] getBuffer()Description copied from interface:ReusableBuffer
Get the buffer backing this ReusableBuffer.- Specified by:
getBuffer
in interfaceReusableBuffer<byte[]>
-
set
Description copied from interface:ReusableBuffer
Set the buffer to the contents of the given ArrowBuf. The internal buffer must resize if it cannot fit the contents of the data.- Specified by:
set
in interfaceReusableBuffer<byte[]>
- Parameters:
srcBytes
- the data to copy fromstart
- the first position of the new datalen
- the number of bytes of the new data
-
set
public void set(byte[] srcBytes, long start, long len) - Specified by:
set
in interfaceReusableBuffer<byte[]>
-
equals
-
hashCode
public int hashCode() -
toString
-
setCapacity
protected void setCapacity(int len, boolean keepData) Sets the capacity of this object to at leastlen
bytes. If the current buffer is longer, then the capacity and existing content of the buffer are unchanged. Iflen
is larger than the current capacity, the Text object's capacity is increased to match.- Parameters:
len
- the number of bytes we needkeepData
- should the old data be kept
-