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 newByteRange
with new backing byte[] containing a copy of the content fromthis
range's window.byte
get()
Retrieve the next byte from this range.get
(byte[] dst) Filldst
with bytes from the range, starting fromposition
.get
(byte[] dst, int offset, int length) Filldst
with bytes from the range, starting from the currentposition
.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
.int
getInt()
Retrieve the next int value from this range.int
getLimit()
Return the current limitlong
getLong()
Retrieve the next long value from this range.int
The currentposition
marker.int
The number of bytes remaining between position and the end of the range.short
getShort()
Retrieve the next short value from this range.long
getVLong()
Retrieve the next long value, which is stored as VLong, from this rangebyte
peek()
Retrieve the next byte from this range without incrementing position.put
(byte val) Storeval
at the next position in this range.put
(byte[] val) Store the content ofval
in this range, starting at the next position.put
(byte[] val, int offset, int length) Storelength
bytes fromval
into this range.put
(int index, byte val) Storeval
atindex
.put
(int index, byte[] val) Storeval
atindex
.put
(int index, byte[] val, int offset, int length) Storelength
bytes fromval
into this range, starting atindex
.putInt
(int val) Store intval
at the next position in this range.putInt
(int index, int val) Store the int value atindex
putLong
(int index, long val) Store the long value atindex
putLong
(long val) Store longval
at the next position in this range.putShort
(int index, short val) Store the short value atindex
putShort
(short val) Store shortval
at the next position in this range.int
putVLong
(long val) Store the longval
at the next position as a VLongset
(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.setLimit
(int limit) Limits the byte range upto a specified value.setOffset
(int offset) Update the beginning of this range.setPosition
(int position) Update theposition
index.Create a newByteRange
that points at this range's byte[].shallowCopySubRange
(int innerOffset, int copyLength) Create a newByteRange
that 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, putVLong
Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getPosition
int getPosition()The currentposition
marker. This valuae is 0-indexed, relative to the beginning of the range. -
setPosition
Update theposition
index. 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
Filldst
with bytes from the range, starting fromposition
. This range'sposition
is incremented by the length ofdst
, the number of bytes copied.- Parameters:
dst
- the destination of the copy.- Returns:
- this.
-
get
Filldst
with bytes from the range, starting from the currentposition
.length
bytes are copied intodst
, starting atoffset
. This range'sposition
is incremented by the number of bytes copied.- Parameters:
dst
- the destination of the copy.offset
- the offset intodst
to start the copy.length
- the number of bytes to copy intodst
.- Returns:
- this.
-
put
Storeval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putShort
Store shortval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putInt
Store intval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putLong
Store longval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putVLong
Store the longval
at the next position as a VLong- Parameters:
val
- the value to store- Returns:
- number of bytes written
-
put
Store the content ofval
in this range, starting at the next position.- Parameters:
val
- the new value.- Returns:
- this.
-
put
Storelength
bytes fromval
into this range. Bytes fromval
are copied starting atoffset
into the range, starting at the current position.- Parameters:
val
- the new value.offset
- the offset inval
from 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:ByteRange
Nullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever. -
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
. -
setOffset
Description copied from interface:ByteRange
Update the beginning of this range.offset + length
may not be greater thanbytes.length
. -
setLength
Description copied from interface:ByteRange
Update the length of this range.offset + length
should not be greater thanbytes.length
. -
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
. -
put
Description copied from interface:ByteRange
Storeval
atindex
. -
putShort
Description copied from interface:ByteRange
Store the short value atindex
-
putInt
Description copied from interface:ByteRange
Store the int value atindex
-
putLong
Description copied from interface:ByteRange
Store the long value atindex
-
put
Description copied from interface:ByteRange
Storeval
atindex
. -
put
Description copied from interface:ByteRange
Storelength
bytes fromval
into this range, starting atindex
. Bytes fromval
are copied starting atoffset
into the range. -
deepCopy
Description copied from interface:ByteRange
Create a newByteRange
with new backing byte[] containing a copy of the content fromthis
range's window. -
shallowCopy
Description copied from interface:ByteRange
Create a newByteRange
that 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:
shallowCopy
in interfaceByteRange
- Returns:
- new
ByteRange
object referencing this range's byte[].
-
shallowCopySubRange
Description copied from interface:ByteRange
Create a newByteRange
that 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:
shallowCopySubRange
in interfaceByteRange
- Parameters:
innerOffset
- First byte of clone will be this.offset + copyOffset.copyLength
- Number of bytes in the clone.- Returns:
- new
ByteRange
object referencing this range's byte[].
-