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
FieldsModifier and TypeFieldDescriptionprotected byte[]The array containing the bytes in this range.protected intVariable for lazy-caching the hashCode of this range.protected intThe number of bytes in the range.protected intThe index of the first byte in this range.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidintBitwise comparison of each byte in the array.voiddeepCopySubRangeTo(int innerOffset, int copyLength, byte[] destination, int destinationOffset) Wrapper for System.arraycopy.voiddeepCopyTo(byte[] destination, int destinationOffset) Wrapper for System.arraycopy.byte[]Instantiate a new byte[] with exact length, which is at least 24 bytes + length.booleanbyteget(int index) Retrieve the byte atindex.get(int index, byte[] dst) Filldstwith bytes from the range, starting fromindex.get(int index, byte[] dst, int offset, int length) Filldstwith bytes from the range, starting fromindex.byte[]getBytes()The underlying byte[].intgetInt(int index) Retrieve the int value atindexintThe length of the range.longgetLong(int index) Retrieve the long value atindexintThe offset, the index into the underlying byte[] at which this range begins.shortgetShort(int index) Retrieve the short value atindexlonggetVLong(int index) Retrieve the long value atindexwhich is stored as VLongstatic intgetVLongSize(long val) inthashCode()booleanisEmpty()Returns true when this range is of zero length, false otherwise.static booleanReturns true whenrangeis of zero length, false otherwise.protected booleanset(byte[] bytes) Reuse thisByteRangeover a new byte[].set(byte[] bytes, int offset, int length) Reuse thisByteRangeover a new byte[].set(int capacity) Reuse thisByteRangeover 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:ByteRangeThe underlying byte[]. -
set
Description copied from interface:ByteRangeReuse thisByteRangeover a new byte[].offsetis set to 0 andlengthis set tocapacity. -
set
Description copied from interface:ByteRangeReuse thisByteRangeover a new byte[].offsetis set to 0 andlengthis set tobytes.length. A nullbytesIS supported, in which case this method will behave equivalently toByteRange.unset(). -
set
Description copied from interface:ByteRangeReuse thisByteRangeover a new byte[]. A nullbytesIS supported, in which case this method will behave equivalently toByteRange.unset(), regardless of the values ofoffsetandlength. -
getOffset
Description copied from interface:ByteRangeThe offset, the index into the underlying byte[] at which this range begins. -
setOffset
Description copied from interface:ByteRangeUpdate the beginning of this range.offset + lengthmay not be greater thanbytes.length. -
getLength
Description copied from interface:ByteRangeThe length of the range. -
setLength
Description copied from interface:ByteRangeUpdate the length of this range.offset + lengthshould not be greater thanbytes.length. -
isEmpty
Description copied from interface:ByteRangeReturns true when this range is of zero length, false otherwise. -
isEmpty
Returns true whenrangeis of zero length, false otherwise. -
get
Description copied from interface:ByteRangeRetrieve the byte atindex. -
get
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex. -
get
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex.lengthbytes are copied intodst, starting atoffset. -
getShort
Description copied from interface:ByteRangeRetrieve the short value atindex -
getInt
Description copied from interface:ByteRangeRetrieve the int value atindex -
getLong
Description copied from interface:ByteRangeRetrieve the long value atindex -
getVLong
Description copied from interface:ByteRangeRetrieve the long value atindexwhich is stored as VLong -
getVLongSize
-
deepCopyToNewArray
Description copied from interface:ByteRangeInstantiate a new byte[] with exact length, which is at least 24 bytes + length. Copy the contents of this range into it.- Specified by:
deepCopyToNewArrayin interfaceByteRange- Returns:
- The newly cloned byte[].
-
deepCopyTo
Description copied from interface:ByteRangeWrapper for System.arraycopy. Copy the contents of this range into the provided array.- Specified by:
deepCopyToin 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:ByteRangeWrapper for System.arraycopy. Copy the contents of this range into the provided array.- Specified by:
deepCopySubRangeToin 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:
compareToin interfaceComparable<ByteRange>
-
toString
-