Class AbstractByteRange
- java.lang.Object
-
- com.mapr.org.apache.hadoop.hbase.util.AbstractByteRange
-
- Direct Known Subclasses:
AbstractPositionedByteRange,SimpleByteRange
public abstract class AbstractByteRange extends java.lang.Object implements ByteRange
An abstract implementation of the ByteRange API
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bytesThe array containing the bytes in this range.protected inthashVariable for lazy-caching the hashCode of this range.protected intlengthThe number of bytes in the range.protected intoffsetThe index of the first byte in this range.static intUNSET_HASH_VALUE
-
Constructor Summary
Constructors Constructor Description AbstractByteRange()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclearHashCache()intcompareTo(ByteRange other)Bitwise 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[]deepCopyToNewArray()Instantiate a new byte[] with exact length, which is at least 24 bytes + length.byteget(int index)Retrieve the byte atindex.ByteRangeget(int index, byte[] dst)Filldstwith bytes from the range, starting fromindex.ByteRangeget(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 atindexintgetLength()The length of the range.longgetLong(int index)Retrieve the long value atindexintgetOffset()The 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 booleanisEmpty(ByteRange range)protected booleanisHashCached()abstract 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 VLongByteRangeset(byte[] bytes)Reuse thisByteRangeover a new byte[].ByteRangeset(byte[] bytes, int offset, int length)Reuse thisByteRangeover a new byte[].ByteRangeset(int capacity)Reuse thisByteRangeover a new byte[].ByteRangesetLength(int length)Update the length of this range.ByteRangesetOffset(int offset)Update the beginning of this range.java.lang.StringtoString()abstract ByteRangeunset()Nullifies this ByteRange.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.mapr.org.apache.hadoop.hbase.util.ByteRange
deepCopy, shallowCopy, shallowCopySubRange
-
-
-
-
Field Detail
-
UNSET_HASH_VALUE
public static final int UNSET_HASH_VALUE
- See Also:
- Constant Field Values
-
bytes
protected byte[] bytes
The array containing the bytes in this range. It will be >= length.
-
offset
protected int offset
The index of the first byte in this range.ByteRange.get(0)will return bytes[offset].
-
length
protected int length
The number of bytes in the range. Offset + length must be <= bytes.length
-
hash
protected int hash
Variable for lazy-caching the hashCode of this range. Useful for frequently used ranges, long-lived ranges, or long ranges.
-
-
Method Detail
-
getBytes
public byte[] getBytes()
Description copied from interface:ByteRangeThe underlying byte[].
-
unset
public abstract ByteRange unset()
Description copied from interface:ByteRangeNullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.
-
set
public ByteRange set(int capacity)
Description copied from interface:ByteRangeReuse thisByteRangeover a new byte[].offsetis set to 0 andlengthis set tocapacity.
-
set
public ByteRange set(byte[] bytes)
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
public ByteRange set(byte[] bytes, int offset, int length)
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.- Specified by:
getOffsetin interfaceByteRange- See Also:
ByteRange.getBytes()
-
setOffset
public ByteRange setOffset(int offset)
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
public ByteRange setLength(int length)
Description copied from interface:ByteRangeUpdate the length of this range.offset + lengthshould not be greater thanbytes.length.
-
isEmpty
public boolean isEmpty()
-
isEmpty
public static boolean isEmpty(ByteRange range)
- Returns:
- true when
rangeis of zero length, false otherwise.
-
get
public byte get(int index)
Description copied from interface:ByteRangeRetrieve the byte atindex.
-
get
public ByteRange get(int index, byte[] dst)
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex.
-
get
public ByteRange get(int index, byte[] dst, int offset, int length)
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
public abstract ByteRange put(int index, byte val)
Description copied from interface:ByteRangeStorevalatindex.
-
put
public abstract ByteRange put(int index, byte[] val)
Description copied from interface:ByteRangeStorevalatindex.
-
put
public abstract ByteRange put(int index, byte[] val, int offset, int length)
Description copied from interface:ByteRangeStorelengthbytes fromvalinto this range, starting atindex. Bytes fromvalare copied starting atoffsetinto the range.
-
putInt
public abstract ByteRange putInt(int index, int val)
Description copied from interface:ByteRangeStore the int value atindex
-
putLong
public abstract ByteRange putLong(int index, long val)
Description copied from interface:ByteRangeStore the long value atindex
-
putShort
public abstract ByteRange putShort(int index, short val)
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()
- Overrides:
hashCodein classjava.lang.Object
-
isHashCached
protected boolean isHashCached()
-
clearHashCache
protected void clearHashCache()
-
compareTo
public int compareTo(ByteRange other)
Bitwise comparison of each byte in the array. Unsigned comparison, not paying attention to java's signed bytes.- Specified by:
compareToin interfacejava.lang.Comparable<ByteRange>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-