Class ByteSequence

java.lang.Object
org.apache.accumulo.core.data.ByteSequence
All Implemented Interfaces:
Comparable<ByteSequence>
Direct Known Subclasses:
ArrayByteSequence

public abstract class ByteSequence extends Object implements Comparable<ByteSequence>
A sequence of bytes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract byte
    byteAt(int i)
    Gets a byte within this sequence.
    static int
    Compares the two given byte sequences, byte by byte, returning a negative, zero, or positive result if the first sequence is less than, equal to, or greater than the second.
    int
     
    boolean
     
    abstract byte[]
    Gets the backing byte array for this sequence.
    int
     
    abstract boolean
    Determines whether this sequence is backed by a byte array.
    abstract int
    Gets the length of this sequence.
    abstract int
    Gets the offset for this sequence.
    abstract ByteSequence
    subSequence(int start, int end)
    Returns a portion of this sequence.
    abstract byte[]
    Returns a byte array containing the bytes in this sequence.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ByteSequence

      public ByteSequence()
  • Method Details

    • byteAt

      public abstract byte byteAt(int i)
      Gets a byte within this sequence.
      Parameters:
      i - index into sequence
      Returns:
      byte
      Throws:
      IllegalArgumentException - if i is out of range
    • length

      public abstract int length()
      Gets the length of this sequence.
      Returns:
      sequence length
    • subSequence

      public abstract ByteSequence subSequence(int start, int end)
      Returns a portion of this sequence.
      Parameters:
      start - index of subsequence start (inclusive)
      end - index of subsequence end (exclusive)
    • toArray

      public abstract byte[] toArray()
      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.
      Returns:
      byte array
    • isBackedByArray

      public abstract boolean isBackedByArray()
      Determines whether this sequence is backed by a byte array.
      Returns:
      true if sequence is backed by a byte array
    • getBackingArray

      public abstract byte[] getBackingArray()
      Gets the backing byte array for this sequence.
      Returns:
      byte array
    • offset

      public abstract int offset()
      Gets the offset for this sequence. This value represents the starting point for the sequence in the backing array, if there is one.
      Returns:
      offset (inclusive)
    • compareBytes

      public static int compareBytes(ByteSequence bs1, ByteSequence bs2)
      Compares the two given byte sequences, byte by byte, returning a negative, zero, or positive result if the first sequence is less than, equal to, or greater than the second. The comparison is performed starting with the first byte of each sequence, and proceeds until a pair of bytes differs, or one sequence runs out of byte (is shorter). A shorter sequence is considered less than a longer one.
      Parameters:
      bs1 - first byte sequence to compare
      bs2 - second byte sequence to compare
      Returns:
      comparison result
    • compareTo

      public int compareTo(ByteSequence obs)
      Specified by:
      compareTo in interface Comparable<ByteSequence>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object