Package org.apache.accumulo.core.data
Class ArrayByteSequence
java.lang.Object
org.apache.accumulo.core.data.ByteSequence
org.apache.accumulo.core.data.ArrayByteSequence
- All Implemented Interfaces:
Serializable,Comparable<ByteSequence>
An implementation of
ByteSequence that uses a backing byte array.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArrayByteSequence(byte[] data) Creates a new sequence.ArrayByteSequence(byte[] data, int offset, int length) Creates a new sequence from a subsequence of the given byte array.Creates a new sequence from the given string.ArrayByteSequence(ByteBuffer buffer) Creates a new sequence based on a byte buffer.ArrayByteSequence(ByteSequence byteSequence) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbytebyteAt(int i) Gets a byte within this sequence.byte[]Gets the backing byte array for this sequence.booleanDetermines whether this sequence is backed by a byte array.intlength()Gets the length of this sequence.intoffset()Gets the offset for this sequence.subSequence(int start, int end) Returns a portion of this sequence.byte[]toArray()Returns a byte array containing the bytes in this sequence.toString()Methods inherited from class org.apache.accumulo.core.data.ByteSequence
compareBytes, compareTo, equals, hashCode
-
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 dataoffset- 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
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
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
-
ArrayByteSequence
Copy constructor. Copies contents of byteSequence.- Since:
- 2.0.0
-
-
Method Details
-
byteAt
public byte byteAt(int i) Description copied from class:ByteSequenceGets a byte within this sequence.- Specified by:
byteAtin classByteSequence- Parameters:
i- index into sequence- Returns:
- byte
-
getBackingArray
public byte[] getBackingArray()Description copied from class:ByteSequenceGets the backing byte array for this sequence.- Specified by:
getBackingArrayin classByteSequence- Returns:
- byte array
-
isBackedByArray
public boolean isBackedByArray()Description copied from class:ByteSequenceDetermines whether this sequence is backed by a byte array.- Specified by:
isBackedByArrayin classByteSequence- Returns:
- true if sequence is backed by a byte array
-
length
public int length()Description copied from class:ByteSequenceGets the length of this sequence.- Specified by:
lengthin classByteSequence- Returns:
- sequence length
-
offset
public int offset()Description copied from class:ByteSequenceGets the offset for this sequence. This value represents the starting point for the sequence in the backing array, if there is one.- Specified by:
offsetin classByteSequence- Returns:
- offset (inclusive)
-
subSequence
Description copied from class:ByteSequenceReturns a portion of this sequence.- Specified by:
subSequencein classByteSequence- Parameters:
start- index of subsequence start (inclusive)end- index of subsequence end (exclusive)
-
toArray
public byte[] toArray()Description copied from class:ByteSequenceReturns 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:
toArrayin classByteSequence- Returns:
- byte array
-
toString
-