Class AbstractByteRange
java.lang.Object
com.mapr.org.apache.hadoop.hbase.util.AbstractByteRange
- All Implemented Interfaces:
ByteRange,Comparable<ByteRange>
- Direct Known Subclasses:
AbstractPositionedByteRange,SimpleByteRange
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.byteget(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()static booleanprotected booleanabstract ByteRangeput(int index, byte val) Storevalatindex.abstract ByteRangeput(int index, byte[] val) Storevalatindex.abstract ByteRangeput(int index, byte[] val, int offset, int length) Storelengthbytes fromvalinto this range, starting atindex.abstract ByteRangeputInt(int index, int val) Store the int value atindexabstract ByteRangeputLong(int index, long val) Store the long value atindexabstract ByteRangeputShort(int index, short val) Store the short value atindexabstract intputVLong(int index, long val) Store the long value atindexas a VLongset(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()abstract ByteRangeunset()Nullifies this ByteRange.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.mapr.org.apache.hadoop.hbase.util.ByteRange
deepCopy, shallowCopy, shallowCopySubRange
-
Field Details
-
UNSET_HASH_VALUE
public static final int UNSET_HASH_VALUE- See Also:
-
bytes
protected byte[] bytesThe array containing the bytes in this range. It will be >= length. -
offset
protected int offsetThe index of the first byte in this range.ByteRange.get(0)will return bytes[offset]. -
length
protected int lengthThe number of bytes in the range. Offset + length must be <= bytes.length -
hash
protected int hashVariable 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
public byte[] getBytes()Description copied from interface:ByteRangeThe underlying byte[]. -
unset
Description copied from interface:ByteRangeNullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever. -
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
public int 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
public int 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
public boolean isEmpty() -
isEmpty
- Returns:
- true when
rangeis of zero length, false otherwise.
-
get
public byte get(int index) 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
public short getShort(int index) Description copied from interface:ByteRangeRetrieve the short value atindex -
getInt
public int getInt(int index) Description copied from interface:ByteRangeRetrieve the int value atindex -
getLong
public long getLong(int index) Description copied from interface:ByteRangeRetrieve the long value atindex -
getVLong
public long getVLong(int index) Description copied from interface:ByteRangeRetrieve the long value atindexwhich is stored as VLong -
getVLongSize
public static int getVLongSize(long val) -
put
Description copied from interface:ByteRangeStorevalatindex. -
put
Description copied from interface:ByteRangeStorevalatindex. -
put
Description copied from interface:ByteRangeStorelengthbytes fromvalinto this range, starting atindex. Bytes fromvalare copied starting atoffsetinto the range. -
putInt
Description copied from interface:ByteRangeStore the int value atindex -
putLong
Description copied from interface:ByteRangeStore the long value atindex -
putShort
Description copied from interface:ByteRangeStore the short value atindex -
putVLong
public abstract int putVLong(int index, long val) Description copied from interface:ByteRangeStore the long value atindexas a VLong -
deepCopyToNewArray
public byte[] 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
public void deepCopyTo(byte[] destination, int destinationOffset) 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
public int hashCode() -
isHashCached
protected boolean isHashCached() -
clearHashCache
protected void clearHashCache() -
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
-