Package org.apache.hadoop.hbase.util
Class SimplePositionedByteRange
java.lang.Object
org.apache.hadoop.hbase.util.AbstractByteRange
org.apache.hadoop.hbase.util.AbstractPositionedByteRange
org.apache.hadoop.hbase.util.SimplePositionedByteRange
- All Implemented Interfaces:
Comparable<ByteRange>
,ByteRange
,PositionedByteRange
Extends the basic
SimpleMutableByteRange
implementation with position support and it is a
readonly version. 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
Fields inherited from class org.apache.hadoop.hbase.util.AbstractPositionedByteRange
limit, position
Fields inherited from class org.apache.hadoop.hbase.util.AbstractByteRange
bytes, hash, length, offset, UNSET_HASH_VALUE
-
Constructor Summary
ConstructorDescriptionCreate a newPositionedByteRange
lacking a backing array and with an undefined viewport.SimplePositionedByteRange
(byte[] bytes) Create a newPositionedByteRange
over the providedbytes
.SimplePositionedByteRange
(byte[] bytes, int offset, int length) Create a newPositionedByteRange
over the providedbytes
.SimplePositionedByteRange
(int capacity) Create a newPositionedByteRange
over a new backing array of sizecapacity
. -
Method Summary
Modifier and TypeMethodDescriptiondeepCopy()
Create a newByteRange
with new backing byte[] containing a copy of the content fromthis
range's window.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
.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
(int index, long val) Store the long value atindex
as a VLongint
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[].setLimit
(int limit) Limits the byte range upto a specified value.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 class org.apache.hadoop.hbase.util.AbstractPositionedByteRange
get, get, get, getInt, getLimit, getLong, getPosition, getRemaining, getShort, getVLong, peek, setLength, setOffset, setPosition
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
Methods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
SimplePositionedByteRange
public SimplePositionedByteRange()Create a newPositionedByteRange
lacking a backing array and with an undefined viewport. -
SimplePositionedByteRange
Create a newPositionedByteRange
over a new backing array of sizecapacity
. The range's offset and length are 0 andcapacity
, respectively.- Parameters:
capacity
- the size of the backing array.
-
SimplePositionedByteRange
Create a newPositionedByteRange
over the providedbytes
.- Parameters:
bytes
- The array to wrap.
-
SimplePositionedByteRange
Create a newPositionedByteRange
over the providedbytes
.- Parameters:
bytes
- The array to wrap.offset
- The offset intobytes
considered the beginning of this range.length
- The length of this range.
-
-
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 classAbstractPositionedByteRange
- 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 classAbstractPositionedByteRange
- 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 classAbstractPositionedByteRange
- Parameters:
bytes
- The array to wrap.offset
- The offset intobytes
considered the beginning of this range.length
- The length of this range.- Returns:
- this.
-
put
Description copied from interface:PositionedByteRange
Storeval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putShort
Description copied from interface:PositionedByteRange
Store shortval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putInt
Description copied from interface:PositionedByteRange
Store intval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putLong
Description copied from interface:PositionedByteRange
Store longval
at the next position in this range.- Parameters:
val
- the new value.- Returns:
- this.
-
putVLong
Description copied from interface:PositionedByteRange
Store the longval
at the next position as a VLong- Parameters:
val
- the value to store- Returns:
- number of bytes written
-
put
Description copied from interface:PositionedByteRange
Store the content ofval
in this range, starting at the next position.- Parameters:
val
- the new value.- Returns:
- this.
-
put
Description copied from interface:PositionedByteRange
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.
-
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 classAbstractPositionedByteRange
- 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 classAbstractPositionedByteRange
- 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.
-
put
Description copied from interface:ByteRange
Storeval
atindex
.- Parameters:
index
- the index in the range whereval
is stored.val
- the value to store.- Returns:
- this.
-
putShort
Description copied from interface:ByteRange
Store the short value atindex
- Parameters:
index
- the index in the range whereval
is storedval
- the value to store
-
putInt
Description copied from interface:ByteRange
Store the int value atindex
- Parameters:
index
- the index in the range whereval
is storedval
- the value to store
-
putVLong
Description copied from interface:ByteRange
Store the long value atindex
as a VLong- Parameters:
index
- the index in the range whereval
is storedval
- the value to store- Returns:
- number of bytes written
-
putLong
Description copied from interface:ByteRange
Store the long value atindex
- Parameters:
index
- the index in the range whereval
is storedval
- the value to store
-
put
Description copied from interface:ByteRange
Storeval
atindex
.- Parameters:
index
- the index in the range whereval
is stored.val
- the value to store.- Returns:
- this.
-
put
Description copied from interface:ByteRange
Storelength
bytes fromval
into this range, starting atindex
. Bytes fromval
are copied starting atoffset
into the range.- Parameters:
index
- position in this range to start the copy.val
- the value to store.offset
- the offset inval
from which to start copying.length
- the number of bytes to copy fromval
.- Returns:
- this.
-
deepCopy
Description copied from interface:ByteRange
Create a newByteRange
with new backing byte[] containing a copy of the content fromthis
range's window.- Returns:
- Deep copy
-
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.- 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.- 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[].
-
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
- Overrides:
setLimit
in classAbstractPositionedByteRange
-
unset
Description copied from interface:ByteRange
Nullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.
-