Class DynamicByteArray

java.lang.Object
org.apache.orc.impl.DynamicByteArray

public final class DynamicByteArray extends Object
A class that is a growable array of bytes. Growth is managed in terms of chunks that are allocated when needed.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    DynamicByteArray(int numChunks, int chunkSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    add(byte value)
     
    int
    add(byte[] value, int valueOffset, int valueLength)
    Copy a slice of a byte array into our buffer.
    void
    Clear the array to its original pristine state.
    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.
    byte[]
    get()
    Gets all the bytes of the array.
    byte
    get(int index)
     
    get(int offset, int length)
     
    long
    Get the size of the buffers.
    void
    Read the entire stream into this array.
    void
    set(int index, byte value)
     
    void
    setByteBuffer(ByteBuffer result, int offset, int length)
     
    void
    setText(Text result, int offset, int length)
    Set a text value from the bytes in this dynamic array.
    int
    Get the size of the array.
     
    void
    write(OutputStream out, int offset, int length)
    Write out a range of this dynamic array to an output stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 from
      valueOffset - the first location to copy from value
      valueLength - the number of bytes to copy from value
      Returns:
      the offset of the start of the value
    • readAll

      public void readAll(InputStream in) throws IOException
      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 bytes
      otherOffset - start offset in the other array
      otherLength - number of bytes in the other array
      ourOffset - the offset in our array
      ourLength - 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

      public void setText(Text result, int offset, int length)
      Set a text value from the bytes in this dynamic array.
      Parameters:
      result - the value to set
      offset - the start of the bytes to copy
      length - the number of bytes to copy
    • write

      public void write(OutputStream out, int offset, int length) throws IOException
      Write out a range of this dynamic array to an output stream.
      Parameters:
      out - the stream to write to
      offset - the first offset to write
      length - the number of bytes to write
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setByteBuffer

      public void setByteBuffer(ByteBuffer result, int offset, int length)
    • get

      public byte[] get()
      Gets all the bytes of the array.
      Returns:
      Bytes of the array
    • get

      public ByteBuffer get(int offset, int length)
    • getSizeInBytes

      public long getSizeInBytes()
      Get the size of the buffers.