Package org.apache.accumulo.core.data
Class ByteSequence
java.lang.Object
org.apache.accumulo.core.data.ByteSequence
- All Implemented Interfaces:
Comparable<ByteSequence>
- Direct Known Subclasses:
ArrayByteSequence
A sequence of bytes.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract byte
byteAt
(int i) Gets a byte within this sequence.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.int
compareTo
(ByteSequence obs) boolean
abstract byte[]
Gets the backing byte array for this sequence.int
hashCode()
abstract boolean
Determines whether this sequence is backed by a byte array.abstract int
length()
Gets the length of this sequence.abstract int
offset()
Gets the offset for this sequence.abstract ByteSequence
subSequence
(int start, int end) Returns a portion of this sequence.abstract byte[]
toArray()
Returns a byte array containing the bytes in this sequence.
-
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
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
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 comparebs2
- second byte sequence to compare- Returns:
- comparison result
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ByteSequence>
-
equals
-
hashCode
public int hashCode()
-