Class ArrayByteSequence

java.lang.Object
org.apache.accumulo.core.data.ByteSequence
org.apache.accumulo.core.data.ArrayByteSequence
All Implemented Interfaces:
Serializable, Comparable<ByteSequence>

public class ArrayByteSequence extends ByteSequence implements Serializable
An implementation of ByteSequence that uses a backing byte array.
See Also:
  • Field Details

    • data

      protected byte[] data
    • offset

      protected int offset
    • length

      protected int length
  • Constructor Details

    • ArrayByteSequence

      public ArrayByteSequence(byte[] data)
      Creates a new sequence. The given byte array is used directly as the backing array, so later changes made to the array reflect into the new sequence.
      Parameters:
      data - byte data
    • ArrayByteSequence

      public ArrayByteSequence(byte[] data, int offset, int length)
      Creates a new sequence from a subsequence of the given byte array. The given byte array is used directly as the backing array, so later changes made to the (relevant portion of the) array reflect into the new sequence.
      Parameters:
      data - byte data
      offset - starting offset in byte array (inclusive)
      length - number of bytes to include in sequence
      Throws:
      IllegalArgumentException - if the offset or length are out of bounds for the given byte array
    • ArrayByteSequence

      public ArrayByteSequence(String s)
      Creates a new sequence from the given string. The bytes are determined from the string using the default platform encoding.
      Parameters:
      s - string to represent as bytes
    • ArrayByteSequence

      public ArrayByteSequence(ByteBuffer buffer)
      Creates a new sequence based on a byte buffer. If the byte buffer has an array, that array (and the buffer's offset and limit) are used; otherwise, a new backing array is created and a relative bulk get is performed to transfer the buffer's contents (starting at its current position and not beyond its limit).
      Parameters:
      buffer - byte buffer
  • Method Details

    • byteAt

      public byte byteAt(int i)
      Description copied from class: ByteSequence
      Gets a byte within this sequence.
      Specified by:
      byteAt in class ByteSequence
      Parameters:
      i - index into sequence
      Returns:
      byte
    • getBackingArray

      public byte[] getBackingArray()
      Description copied from class: ByteSequence
      Gets the backing byte array for this sequence.
      Specified by:
      getBackingArray in class ByteSequence
      Returns:
      byte array
    • isBackedByArray

      public boolean isBackedByArray()
      Description copied from class: ByteSequence
      Determines whether this sequence is backed by a byte array.
      Specified by:
      isBackedByArray in class ByteSequence
      Returns:
      true if sequence is backed by a byte array
    • length

      public int length()
      Description copied from class: ByteSequence
      Gets the length of this sequence.
      Specified by:
      length in class ByteSequence
      Returns:
      sequence length
    • offset

      public int offset()
      Description copied from class: ByteSequence
      Gets the offset for this sequence. This value represents the starting point for the sequence in the backing array, if there is one.
      Specified by:
      offset in class ByteSequence
      Returns:
      offset (inclusive)
    • subSequence

      public ByteSequence subSequence(int start, int end)
      Description copied from class: ByteSequence
      Returns a portion of this sequence.
      Specified by:
      subSequence in class ByteSequence
      Parameters:
      start - index of subsequence start (inclusive)
      end - index of subsequence end (exclusive)
    • toArray

      public byte[] toArray()
      Description copied from class: ByteSequence
      Returns a byte array containing the bytes in this sequence. This method may copy the sequence data or may return a backing byte array directly.
      Specified by:
      toArray in class ByteSequence
      Returns:
      byte array
    • toString

      public String toString()
      Overrides:
      toString in class Object