Package org.apache.orc.impl
Class DynamicByteArray
java.lang.Object
org.apache.orc.impl.DynamicByteArray
A class that is a growable array of bytes. Growth is managed in terms of
chunks that are allocated when needed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadd(byte value) intadd(byte[] value, int valueOffset, int valueLength) Copy a slice of a byte array into our buffer.voidclear()Clear the array to its original pristine state.intcompare(byte[] other, int otherOffset, int otherLength, int ourOffset, int ourLength) Byte compare a set of bytes against the bytes in this dynamic array.byte[]get()Gets all the bytes of the array.byteget(int index) get(int offset, int length) longGet the size of the buffers.voidreadAll(InputStream in) Read the entire stream into this array.voidset(int index, byte value) voidsetByteBuffer(ByteBuffer result, int offset, int length) voidSet a text value from the bytes in this dynamic array.intsize()Get the size of the array.toString()voidwrite(OutputStream out, int offset, int length) Write out a range of this dynamic array to an output stream.
-
Constructor Details
-
DynamicByteArray
public DynamicByteArray() -
DynamicByteArray
public DynamicByteArray(int numChunks, int chunkSize)
-
-
Method Details
-
get
public byte get(int index) -
set
public void set(int index, byte value) -
add
public int add(byte value) -
add
public int add(byte[] value, int valueOffset, int valueLength) Copy a slice of a byte array into our buffer.- Parameters:
value- the array to copy fromvalueOffset- the first location to copy from valuevalueLength- the number of bytes to copy from value- Returns:
- the offset of the start of the value
-
readAll
Read the entire stream into this array.- Parameters:
in- the stream to read from- Throws:
IOException
-
compare
public int compare(byte[] other, int otherOffset, int otherLength, int ourOffset, int ourLength) Byte compare a set of bytes against the bytes in this dynamic array.- Parameters:
other- source of the other bytesotherOffset- start offset in the other arrayotherLength- number of bytes in the other arrayourOffset- the offset in our arrayourLength- the number of bytes in our array- Returns:
- negative for less, 0 for equal, positive for greater
-
size
public int size()Get the size of the array.- Returns:
- the number of bytes in the array
-
clear
public void clear()Clear the array to its original pristine state. -
setText
Set a text value from the bytes in this dynamic array.- Parameters:
result- the value to setoffset- the start of the bytes to copylength- the number of bytes to copy
-
write
Write out a range of this dynamic array to an output stream.- Parameters:
out- the stream to write tooffset- the first offset to writelength- the number of bytes to write- Throws:
IOException
-
toString
-
setByteBuffer
-
get
public byte[] get()Gets all the bytes of the array.- Returns:
- Bytes of the array
-
get
-
getSizeInBytes
public long getSizeInBytes()Get the size of the buffers.
-