Package org.apache.hadoop.hbase.util
Class AbstractPositionedByteRange
java.lang.Object
org.apache.hadoop.hbase.util.AbstractByteRange
org.apache.hadoop.hbase.util.AbstractPositionedByteRange
- All Implemented Interfaces:
Comparable<ByteRange>
,ByteRange
,PositionedByteRange
- Direct Known Subclasses:
SimplePositionedByteRange
,SimplePositionedMutableByteRange
@Private
@Evolving
public abstract class AbstractPositionedByteRange
extends AbstractByteRange
implements PositionedByteRange
Extends the basic
SimpleByteRange
implementation with position support. position
is considered transient, not fundamental to the definition of the range, and does not participate
in AbstractByteRange.compareTo(ByteRange)
, AbstractByteRange.hashCode()
, or AbstractByteRange.equals(Object)
.
Position
is retained by copy operations.-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected int
The current index into the range.Fields inherited from class org.apache.hadoop.hbase.util.AbstractByteRange
bytes, hash, length, offset, UNSET_HASH_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte
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.set
(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.Methods inherited from class org.apache.hadoop.hbase.util.AbstractByteRange
clearHashCache, compareTo, deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, equals, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, getVLongSize, hashCode, isEmpty, isEmpty, isHashCached, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
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
-
Field Details
-
position
The current index into the range. LikeByteBuffer
position, it points to the next value that will be read/written in the array. It provides the appearance of being 0-indexed, even though its value is calculated according to offset.Position is considered transient and does not participate in
AbstractByteRange.equals(Object)
orAbstractByteRange.hashCode()
comparisons. -
limit
-
-
Constructor Details
-
AbstractPositionedByteRange
public AbstractPositionedByteRange()
-
-
Method Details
-
set
Description copied from interface:ByteRange
Reuse thisByteRange
over a new byte[].offset
is set to 0 andlength
is set tocapacity
.- Specified by:
set
in interfaceByteRange
- Specified by:
set
in interfacePositionedByteRange
- Overrides:
set
in classAbstractByteRange
- Parameters:
capacity
- the size of a new byte[].
-
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()
.- Specified by:
set
in interfaceByteRange
- Specified by:
set
in interfacePositionedByteRange
- Overrides:
set
in classAbstractByteRange
- Parameters:
bytes
- the array to wrap.
-
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
.- Specified by:
set
in interfaceByteRange
- Specified by:
set
in interfacePositionedByteRange
- Overrides:
set
in classAbstractByteRange
- Parameters:
bytes
- The array to wrap.offset
- The offset intobytes
considered the beginning of this range.length
- The length of this range.- Returns:
- this.
-
setOffset
Update the beginning of this range.offset + length
may not be greater thanbytes.length
. Resetsposition
to 0. the new start of this range.- Specified by:
setOffset
in interfaceByteRange
- Specified by:
setOffset
in interfacePositionedByteRange
- Overrides:
setOffset
in classAbstractByteRange
- Parameters:
offset
- the new start of this range.- Returns:
- this.
-
setLength
Update the length of this range.offset + length
should not be greater thanbytes.length
. Ifposition
is greater than the newlength
, setsposition
tolength
. The new length of this range.- Specified by:
setLength
in interfaceByteRange
- Specified by:
setLength
in interfacePositionedByteRange
- Overrides:
setLength
in classAbstractByteRange
- Parameters:
length
- The new length of this range.- Returns:
- this.
-
getPosition
Description copied from interface:PositionedByteRange
The currentposition
marker. This valuae is 0-indexed, relative to the beginning of the range.- Specified by:
getPosition
in interfacePositionedByteRange
-
setPosition
Description copied from interface:PositionedByteRange
Update theposition
index. May not be greater thanlength
.- Specified by:
setPosition
in interfacePositionedByteRange
- Parameters:
position
- the new position in this range.- Returns:
- this.
-
getRemaining
Description copied from interface:PositionedByteRange
The number of bytes remaining between position and the end of the range.- Specified by:
getRemaining
in interfacePositionedByteRange
-
peek
Description copied from interface:PositionedByteRange
Retrieve the next byte from this range without incrementing position.- Specified by:
peek
in interfacePositionedByteRange
-
get
Description copied from interface:PositionedByteRange
Retrieve the next byte from this range.- Specified by:
get
in interfacePositionedByteRange
-
get
Description copied from interface:PositionedByteRange
Filldst
with bytes from the range, starting fromposition
. This range'sposition
is incremented by the length ofdst
, the number of bytes copied.- Specified by:
get
in interfacePositionedByteRange
- Parameters:
dst
- the destination of the copy.- Returns:
- this.
-
get
Description copied from interface:PositionedByteRange
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.- Specified by:
get
in interfacePositionedByteRange
- 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.
-
get
Description copied from interface:ByteRange
Filldst
with bytes from the range, starting fromindex
.- Specified by:
get
in interfaceByteRange
- Specified by:
get
in interfacePositionedByteRange
- Overrides:
get
in classAbstractByteRange
- Parameters:
index
- zero-based index into this range.dst
- the destination of the copy.- Returns:
- this.
-
get
Description copied from interface:ByteRange
Filldst
with bytes from the range, starting fromindex
.length
bytes are copied intodst
, starting atoffset
.- Specified by:
get
in interfaceByteRange
- Specified by:
get
in interfacePositionedByteRange
- Overrides:
get
in classAbstractByteRange
- Parameters:
index
- zero-based index into this range.dst
- the destination of the copy.offset
- the offset intodst
to start the copy.length
- the number of bytes to copy intodst
.- Returns:
- this.
-
getShort
Description copied from interface:PositionedByteRange
Retrieve the next short value from this range.- Specified by:
getShort
in interfacePositionedByteRange
-
getInt
Description copied from interface:PositionedByteRange
Retrieve the next int value from this range.- Specified by:
getInt
in interfacePositionedByteRange
-
getLong
Description copied from interface:PositionedByteRange
Retrieve the next long value from this range.- Specified by:
getLong
in interfacePositionedByteRange
-
getVLong
Description copied from interface:PositionedByteRange
Retrieve the next long value, which is stored as VLong, from this range- Specified by:
getVLong
in interfacePositionedByteRange
- Returns:
- the long value which is stored as VLong
-
setLimit
Description copied from interface:PositionedByteRange
Limits the byte range upto a specified value. Limit cannot be greater than capacity- Specified by:
setLimit
in interfacePositionedByteRange
-
getLimit
Description copied from interface:PositionedByteRange
Return the current limit- Specified by:
getLimit
in interfacePositionedByteRange
-