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, positionFields inherited from class org.apache.hadoop.hbase.util.AbstractByteRange
bytes, hash, length, offset, UNSET_HASH_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newPositionedByteRangelacking a backing array and with an undefined viewport.SimplePositionedByteRange(byte[] bytes) Create a newPositionedByteRangeover the providedbytes.SimplePositionedByteRange(byte[] bytes, int offset, int length) Create a newPositionedByteRangeover the providedbytes.SimplePositionedByteRange(int capacity) Create a newPositionedByteRangeover a new backing array of sizecapacity. -
Method Summary
Modifier and TypeMethodDescriptiondeepCopy()Create a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window.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.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(int index, long val) Store the long value atindexas a VLongintputVLong(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[].setLimit(int limit) Limits the byte range upto a specified value.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 class org.apache.hadoop.hbase.util.AbstractPositionedByteRange
get, get, get, getInt, getLimit, getLong, getPosition, getRemaining, getShort, getVLong, peek, setLength, setOffset, setPositionMethods 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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.util.ByteRange
deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, isEmptyMethods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
SimplePositionedByteRange
public SimplePositionedByteRange()Create a newPositionedByteRangelacking a backing array and with an undefined viewport. -
SimplePositionedByteRange
Create a newPositionedByteRangeover 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 newPositionedByteRangeover the providedbytes.- Parameters:
bytes- The array to wrap.
-
SimplePositionedByteRange
Create a newPositionedByteRangeover the providedbytes.- Parameters:
bytes- The array to wrap.offset- The offset intobytesconsidered the beginning of this range.length- The length of this range.
-
-
Method Details
-
set
Description copied from interface:ByteRangeReuse thisByteRangeover a new byte[].offsetis set to 0 andlengthis set tocapacity.- Specified by:
setin interfaceByteRange- Specified by:
setin interfacePositionedByteRange- Overrides:
setin classAbstractPositionedByteRange- Parameters:
capacity- the size of a new byte[].
-
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().- Specified by:
setin interfaceByteRange- Specified by:
setin interfacePositionedByteRange- Overrides:
setin classAbstractPositionedByteRange- Parameters:
bytes- the array to wrap.
-
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.- Specified by:
setin interfaceByteRange- Specified by:
setin interfacePositionedByteRange- Overrides:
setin classAbstractPositionedByteRange- Parameters:
bytes- The array to wrap.offset- The offset intobytesconsidered the beginning of this range.length- The length of this range.- Returns:
- this.
-
put
Description copied from interface:PositionedByteRangeStorevalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putShort
Description copied from interface:PositionedByteRangeStore shortvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putInt
Description copied from interface:PositionedByteRangeStore intvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putLong
Description copied from interface:PositionedByteRangeStore longvalat the next position in this range.- Parameters:
val- the new value.- Returns:
- this.
-
putVLong
Description copied from interface:PositionedByteRangeStore the longvalat the next position as a VLong- Parameters:
val- the value to store- Returns:
- number of bytes written
-
put
Description copied from interface:PositionedByteRangeStore the content ofvalin this range, starting at the next position.- Parameters:
val- the new value.- Returns:
- this.
-
put
Description copied from interface:PositionedByteRangeStorelengthbytes 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.
-
get
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex.- Specified by:
getin interfaceByteRange- Specified by:
getin interfacePositionedByteRange- Overrides:
getin classAbstractPositionedByteRange- Parameters:
index- zero-based index into this range.dst- the destination of the copy.- Returns:
- this.
-
get
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex.lengthbytes are copied intodst, starting atoffset.- Specified by:
getin interfaceByteRange- Specified by:
getin interfacePositionedByteRange- Overrides:
getin classAbstractPositionedByteRange- Parameters:
index- zero-based index into this range.dst- the destination of the copy.offset- the offset intodstto start the copy.length- the number of bytes to copy intodst.- Returns:
- this.
-
put
Description copied from interface:ByteRangeStorevalatindex.- Parameters:
index- the index in the range wherevalis stored.val- the value to store.- Returns:
- this.
-
putShort
Description copied from interface:ByteRangeStore the short value atindex- Parameters:
index- the index in the range wherevalis storedval- the value to store
-
putInt
Description copied from interface:ByteRangeStore the int value atindex- Parameters:
index- the index in the range wherevalis storedval- the value to store
-
putVLong
Description copied from interface:ByteRangeStore the long value atindexas a VLong- Parameters:
index- the index in the range wherevalis storedval- the value to store- Returns:
- number of bytes written
-
putLong
Description copied from interface:ByteRangeStore the long value atindex- Parameters:
index- the index in the range wherevalis storedval- the value to store
-
put
Description copied from interface:ByteRangeStorevalatindex.- Parameters:
index- the index in the range wherevalis stored.val- the value to store.- Returns:
- this.
-
put
Description copied from interface:ByteRangeStorelengthbytes fromvalinto this range, starting atindex. Bytes fromvalare copied starting atoffsetinto the range.- Parameters:
index- position in this range to start the copy.val- the value to store.offset- the offset invalfrom which to start copying.length- the number of bytes to copy fromval.- Returns:
- this.
-
deepCopy
Description copied from interface:ByteRangeCreate a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window.- Returns:
- Deep copy
-
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.- 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.- 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[].
-
setLimit
Description copied from interface:PositionedByteRangeLimits the byte range upto a specified value. Limit cannot be greater than capacity- Specified by:
setLimitin interfacePositionedByteRange- Overrides:
setLimitin classAbstractPositionedByteRange
-
unset
Description copied from interface:ByteRangeNullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.
-