Package org.apache.hadoop.hbase.util
Interface PositionedByteRange
- All Superinterfaces:
ByteRange,Comparable<ByteRange>
- All Known Implementing Classes:
AbstractPositionedByteRange,SimplePositionedByteRange,SimplePositionedMutableByteRange
Extends ByteRange with additional methods to support tracking a consumers position within
the viewport. The API is extended with methods get() and put(byte) for
interacting with the backing array from the current position forward. This frees the caller from
managing their own index into the array.
Designed to be a slimmed-down, mutable alternative to ByteBuffer.
-
Method Summary
Modifier and TypeMethodDescriptiondeepCopy()Create a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window.byteget()Retrieve the next byte from this range.get(byte[] dst) Filldstwith bytes from the range, starting fromposition.get(byte[] dst, int offset, int length) Filldstwith bytes from the range, starting from the currentposition.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.intgetInt()Retrieve the next int value from this range.intgetLimit()Return the current limitlonggetLong()Retrieve the next long value from this range.intThe currentpositionmarker.intThe number of bytes remaining between position and the end of the range.shortgetShort()Retrieve the next short value from this range.longgetVLong()Retrieve the next long value, which is stored as VLong, from this rangebytepeek()Retrieve the next byte from this range without incrementing position.put(byte val) Storevalat the next position in this range.put(byte[] val) Store the content ofvalin this range, starting at the next position.put(byte[] val, int offset, int length) Storelengthbytes fromvalinto this range.put(int index, byte val) Storevalatindex.put(int index, byte[] val) Storevalatindex.put(int index, byte[] val, int offset, int length) Storelengthbytes fromvalinto this range, starting atindex.putInt(int val) Store intvalat the next position in this range.putInt(int index, int val) Store the int value atindexputLong(int index, long val) Store the long value atindexputLong(long val) Store longvalat the next position in this range.putShort(int index, short val) Store the short value atindexputShort(short val) Store shortvalat the next position in this range.intputVLong(long val) Store the longvalat the next position as 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.setLimit(int limit) Limits the byte range upto a specified value.setOffset(int offset) Update the beginning of this range.setPosition(int position) Update thepositionindex.Create a newByteRangethat points at this range's byte[].shallowCopySubRange(int innerOffset, int copyLength) Create a newByteRangethat points at this range's byte[].unset()Nullifies this ByteRange.Methods inherited from interface org.apache.hadoop.hbase.util.ByteRange
deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, isEmpty, putVLongMethods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getPosition
int getPosition()The currentpositionmarker. This valuae is 0-indexed, relative to the beginning of the range. -
setPosition
Update thepositionindex. May not be greater thanlength.- Parameters:
position- the new position in this range.- Returns:
- this.
-
getRemaining
int getRemaining()The number of bytes remaining between position and the end of the range. -
peek
byte peek()Retrieve the next byte from this range without incrementing position. -
get
byte get()Retrieve the next byte from this range. -
getShort
short getShort()Retrieve the next short value from this range. -
getInt
int getInt()Retrieve the next int value from this range. -
getLong
long getLong()Retrieve the next long value from this range. -
getVLong
long getVLong()Retrieve the next long value, which is stored as VLong, from this range- Returns:
- the long value which is stored as VLong
-
get
Filldstwith bytes from the range, starting fromposition. This range'spositionis incremented by the length ofdst, the number of bytes copied.- Parameters:
dst- the destination of the copy.- Returns:
- this.
-
get
Filldstwith bytes from the range, starting from the currentposition.lengthbytes are copied intodst, starting atoffset. This range'spositionis incremented by the number of bytes copied.- Parameters:
dst- the destination of the copy.offset- the offset intodstto start the copy.length- the number of bytes to copy intodst.- Returns:
- this.
-
put
Storevalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putShort
Store shortvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putInt
Store intvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putLong
Store longvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putVLong
Store the longvalat the next position as a VLong- Parameters:
val- the value to store- Returns:
- number of bytes written
-
put
Store the content ofvalin this range, starting at the next position.- Parameters:
val- the new value.- Returns:
- this.
-
put
Storelengthbytes fromvalinto this range. Bytes fromvalare copied starting atoffsetinto the range, starting at the current position.- Parameters:
val- the new value.offset- the offset invalfrom which to start copying.length- the number of bytes to copy fromval.- Returns:
- this.
-
setLimit
Limits the byte range upto a specified value. Limit cannot be greater than capacity -
getLimit
int getLimit()Return the current limit -
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. -
setOffset
Description copied from interface:ByteRangeUpdate the beginning of this range.offset + lengthmay not be greater thanbytes.length. -
setLength
Description copied from interface:ByteRangeUpdate the length of this range.offset + lengthshould not be greater thanbytes.length. -
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. -
put
Description copied from interface:ByteRangeStorevalatindex. -
putShort
Description copied from interface:ByteRangeStore the short value atindex -
putInt
Description copied from interface:ByteRangeStore the int value atindex -
putLong
Description copied from interface:ByteRangeStore the long value atindex -
put
Description copied from interface:ByteRangeStorevalatindex. -
put
Description copied from interface:ByteRangeStorelengthbytes fromvalinto this range, starting atindex. Bytes fromvalare copied starting atoffsetinto the range. -
deepCopy
Description copied from interface:ByteRangeCreate a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window. -
shallowCopy
Description copied from interface:ByteRangeCreate a newByteRangethat points at this range's byte[]. Modifying the shallowCopy will modify the bytes in this range's array. Pass over the hash code if it is already cached.- Specified by:
shallowCopyin interfaceByteRange- Returns:
- new
ByteRangeobject referencing this range's byte[].
-
shallowCopySubRange
Description copied from interface:ByteRangeCreate a newByteRangethat points at this range's byte[]. The new range can have different values for offset and length, but modifying the shallowCopy will modify the bytes in this range's array. Pass over the hash code if it is already cached.- Specified by:
shallowCopySubRangein interfaceByteRange- Parameters:
innerOffset- First byte of clone will be this.offset + copyOffset.copyLength- Number of bytes in the clone.- Returns:
- new
ByteRangeobject referencing this range's byte[].
-