Package org.apache.hadoop.hbase.util
Class AbstractByteRange
java.lang.Object
org.apache.hadoop.hbase.util.AbstractByteRange
- All Implemented Interfaces:
Comparable<ByteRange>
,ByteRange
- Direct Known Subclasses:
AbstractPositionedByteRange
,SimpleByteRange
,SimpleMutableByteRange
An abstract implementation of the ByteRange API
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[]
The array containing the bytes in this range.protected int
Variable for lazy-caching the hashCode of this range.protected int
The number of bytes in the range.protected int
The index of the first byte in this range.static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
int
Bitwise comparison of each byte in the array.void
deepCopySubRangeTo
(int innerOffset, int copyLength, byte[] destination, int destinationOffset) Wrapper for System.arraycopy.void
deepCopyTo
(byte[] destination, int destinationOffset) Wrapper for System.arraycopy.byte[]
Instantiate a new byte[] with exact length, which is at least 24 bytes + length.boolean
byte
get
(int index) Retrieve the byte atindex
.get
(int index, byte[] dst) Filldst
with bytes from the range, starting fromindex
.get
(int index, byte[] dst, int offset, int length) Filldst
with bytes from the range, starting fromindex
.byte[]
getBytes()
The underlying byte[].int
getInt
(int index) Retrieve the int value atindex
int
The length of the range.long
getLong
(int index) Retrieve the long value atindex
int
The offset, the index into the underlying byte[] at which this range begins.short
getShort
(int index) Retrieve the short value atindex
long
getVLong
(int index) Retrieve the long value atindex
which is stored as VLongstatic int
getVLongSize
(long val) int
hashCode()
boolean
isEmpty()
Returns true when this range is of zero length, false otherwise.static boolean
Returns true whenrange
is of zero length, false otherwise.protected boolean
set
(byte[] bytes) Reuse thisByteRange
over a new byte[].set
(byte[] bytes, int offset, int length) Reuse thisByteRange
over a new byte[].set
(int capacity) Reuse thisByteRange
over a new byte[].setLength
(int length) Update the length of this range.setOffset
(int offset) Update the beginning of this range.toString()
-
Field Details
-
UNSET_HASH_VALUE
- See Also:
-
bytes
The array containing the bytes in this range. It will be >= length. -
offset
The index of the first byte in this range.ByteRange.get(0)
will return bytes[offset]. -
length
The number of bytes in the range. Offset + length must be <= bytes.length -
hash
Variable for lazy-caching the hashCode of this range. Useful for frequently used ranges, long-lived ranges, or long ranges.
-
-
Constructor Details
-
AbstractByteRange
public AbstractByteRange()
-
-
Method Details
-
getBytes
Description copied from interface:ByteRange
The underlying byte[]. -
set
Description copied from interface:ByteRange
Reuse thisByteRange
over a new byte[].offset
is set to 0 andlength
is set tocapacity
. -
set
Description copied from interface:ByteRange
Reuse thisByteRange
over a new byte[].offset
is set to 0 andlength
is set tobytes.length
. A nullbytes
IS supported, in which case this method will behave equivalently toByteRange.unset()
. -
set
Description copied from interface:ByteRange
Reuse thisByteRange
over a new byte[]. A nullbytes
IS supported, in which case this method will behave equivalently toByteRange.unset()
, regardless of the values ofoffset
andlength
. -
getOffset
Description copied from interface:ByteRange
The offset, the index into the underlying byte[] at which this range begins. -
setOffset
Description copied from interface:ByteRange
Update the beginning of this range.offset + length
may not be greater thanbytes.length
. -
getLength
Description copied from interface:ByteRange
The length of the range. -
setLength
Description copied from interface:ByteRange
Update the length of this range.offset + length
should not be greater thanbytes.length
. -
isEmpty
Description copied from interface:ByteRange
Returns true when this range is of zero length, false otherwise. -
isEmpty
Returns true whenrange
is of zero length, false otherwise. -
get
Description copied from interface:ByteRange
Retrieve the byte atindex
. -
get
Description copied from interface:ByteRange
Filldst
with bytes from the range, starting fromindex
. -
get
Description copied from interface:ByteRange
Filldst
with bytes from the range, starting fromindex
.length
bytes are copied intodst
, starting atoffset
. -
getShort
Description copied from interface:ByteRange
Retrieve the short value atindex
-
getInt
Description copied from interface:ByteRange
Retrieve the int value atindex
-
getLong
Description copied from interface:ByteRange
Retrieve the long value atindex
-
getVLong
Description copied from interface:ByteRange
Retrieve the long value atindex
which is stored as VLong -
getVLongSize
-
deepCopyToNewArray
Description copied from interface:ByteRange
Instantiate a new byte[] with exact length, which is at least 24 bytes + length. Copy the contents of this range into it.- Specified by:
deepCopyToNewArray
in interfaceByteRange
- Returns:
- The newly cloned byte[].
-
deepCopyTo
Description copied from interface:ByteRange
Wrapper for System.arraycopy. Copy the contents of this range into the provided array.- Specified by:
deepCopyTo
in interfaceByteRange
- Parameters:
destination
- Copy to this arraydestinationOffset
- First index in the destination array.
-
deepCopySubRangeTo
public void deepCopySubRangeTo(int innerOffset, int copyLength, byte[] destination, int destinationOffset) Description copied from interface:ByteRange
Wrapper for System.arraycopy. Copy the contents of this range into the provided array.- Specified by:
deepCopySubRangeTo
in interfaceByteRange
- Parameters:
innerOffset
- Start copying from this index in this source ByteRange. First byte copied is bytes[offset + innerOffset]copyLength
- Copy this many bytesdestination
- Copy to this arraydestinationOffset
- First index in the destination array.
-
hashCode
-
isHashCached
-
clearHashCache
-
equals
-
compareTo
Bitwise comparison of each byte in the array. Unsigned comparison, not paying attention to java's signed bytes.- Specified by:
compareTo
in interfaceComparable<ByteRange>
-
toString
-