Class AbstractPositionedByteRange
- java.lang.Object
-
- com.mapr.org.apache.hadoop.hbase.util.AbstractByteRange
-
- com.mapr.org.apache.hadoop.hbase.util.AbstractPositionedByteRange
-
- All Implemented Interfaces:
ByteRange,PositionedByteRange,java.lang.Comparable<ByteRange>
- Direct Known Subclasses:
SimplePositionedByteRange,SimplePositionedMutableByteRange
public abstract class AbstractPositionedByteRange extends AbstractByteRange implements PositionedByteRange
Extends the basicSimpleByteRangeimplementation with position support.positionis considered transient, not fundamental to the definition of the range, and does not participate inAbstractByteRange.compareTo(ByteRange),AbstractByteRange.hashCode(), orObject.equals(Object).Positionis retained by copy operations.
-
-
Field Summary
Fields Modifier and Type Field Description protected intlimitprotected intpositionThe current index into the range.-
Fields inherited from class com.mapr.org.apache.hadoop.hbase.util.AbstractByteRange
bytes, hash, length, offset, UNSET_HASH_VALUE
-
-
Constructor Summary
Constructors Constructor Description AbstractPositionedByteRange()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract PositionedByteRangedeepCopy()Create a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window.byteget()Retrieve the next byte from this range.PositionedByteRangeget(byte[] dst)Filldstwith bytes from the range, starting fromposition.PositionedByteRangeget(byte[] dst, int offset, int length)Filldstwith bytes from the range, starting from the currentposition.PositionedByteRangeget(int index, byte[] dst)Filldstwith bytes from the range, starting fromindex.PositionedByteRangeget(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.intgetPosition()The currentpositionmarker.intgetRemaining()The 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.abstract PositionedByteRangeput(byte val)Storevalat the next position in this range.abstract PositionedByteRangeput(byte[] val)Store the content ofvalin this range, starting at the next position.abstract PositionedByteRangeput(byte[] val, int offset, int length)Storelengthbytes fromvalinto this range.abstract PositionedByteRangeput(int index, byte val)Storevalatindex.abstract PositionedByteRangeput(int index, byte[] val)Storevalatindex.abstract PositionedByteRangeput(int index, byte[] val, int offset, int length)Storelengthbytes fromvalinto this range, starting atindex.abstract PositionedByteRangeputInt(int val)Store intvalat the next position in this range.abstract PositionedByteRangeputInt(int index, int val)Store the int value atindexabstract PositionedByteRangeputLong(int index, long val)Store the long value atindexabstract PositionedByteRangeputLong(long val)Store longvalat the next position in this range.abstract PositionedByteRangeputShort(int index, short val)Store the short value atindexabstract PositionedByteRangeputShort(short val)Store shortvalat the next position in this range.abstract intputVLong(int index, long val)Store the long value atindexas a VLongabstract intputVLong(long val)Store the longvalat the next position as a VLongPositionedByteRangeset(byte[] bytes)Reuse thisByteRangeover a new byte[].PositionedByteRangeset(byte[] bytes, int offset, int length)Reuse thisByteRangeover a new byte[].PositionedByteRangeset(int capacity)Reuse thisByteRangeover a new byte[].PositionedByteRangesetLength(int length)Update the length of this range.PositionedByteRangesetLimit(int limit)Limits the byte range upto a specified value.PositionedByteRangesetOffset(int offset)Update the beginning of this range.PositionedByteRangesetPosition(int position)Update thepositionindex.abstract PositionedByteRangeshallowCopy()Create a newByteRangethat points at this range's byte[].abstract PositionedByteRangeshallowCopySubRange(int innerOffset, int copyLength)Create a newByteRangethat points at this range's byte[].abstract PositionedByteRangeunset()Nullifies this ByteRange.-
Methods inherited from class com.mapr.org.apache.hadoop.hbase.util.AbstractByteRange
clearHashCache, compareTo, deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, getVLongSize, hashCode, isEmpty, isEmpty, isHashCached, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.mapr.org.apache.hadoop.hbase.util.ByteRange
deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getInt, getLength, getLong, getOffset, getShort, getVLong, isEmpty
-
-
-
-
Field Detail
-
position
protected int position
The current index into the range. LikeByteBufferposition, 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
Object.equals(Object)orAbstractByteRange.hashCode()comparisons.
-
limit
protected int limit
-
-
Method Detail
-
unset
public abstract PositionedByteRange unset()
Description copied from interface:ByteRangeNullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.- Specified by:
unsetin interfaceByteRange- Specified by:
unsetin interfacePositionedByteRange- Specified by:
unsetin classAbstractByteRange- Returns:
- this
-
set
public PositionedByteRange set(int capacity)
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 classAbstractByteRange- Parameters:
capacity- the size of a new byte[].- Returns:
- this
-
set
public PositionedByteRange set(byte[] bytes)
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 classAbstractByteRange- Parameters:
bytes- the array to wrap.- Returns:
- this
-
set
public PositionedByteRange set(byte[] bytes, int offset, int length)
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 classAbstractByteRange- Parameters:
bytes- The array to wrap.offset- The offset intobytesconsidered the beginning of this range.length- The length of this range.- Returns:
- this.
-
setOffset
public PositionedByteRange setOffset(int offset)
Update the beginning of this range.offset + lengthmay not be greater thanbytes.length. Resetspositionto 0.- Specified by:
setOffsetin interfaceByteRange- Specified by:
setOffsetin interfacePositionedByteRange- Overrides:
setOffsetin classAbstractByteRange- Parameters:
offset- the new start of this range.- Returns:
- this.
-
setLength
public PositionedByteRange setLength(int length)
Update the length of this range.offset + lengthshould not be greater thanbytes.length. Ifpositionis greater than the newlength, setspositiontolength.- Specified by:
setLengthin interfaceByteRange- Specified by:
setLengthin interfacePositionedByteRange- Overrides:
setLengthin classAbstractByteRange- Parameters:
length- The new length of this range.- Returns:
- this.
-
getPosition
public int getPosition()
Description copied from interface:PositionedByteRangeThe currentpositionmarker. This valuae is 0-indexed, relative to the beginning of the range.- Specified by:
getPositionin interfacePositionedByteRange
-
setPosition
public PositionedByteRange setPosition(int position)
Description copied from interface:PositionedByteRangeUpdate thepositionindex. May not be greater thanlength.- Specified by:
setPositionin interfacePositionedByteRange- Parameters:
position- the new position in this range.- Returns:
- this.
-
getRemaining
public int getRemaining()
Description copied from interface:PositionedByteRangeThe number of bytes remaining between position and the end of the range.- Specified by:
getRemainingin interfacePositionedByteRange
-
peek
public byte peek()
Description copied from interface:PositionedByteRangeRetrieve the next byte from this range without incrementing position.- Specified by:
peekin interfacePositionedByteRange
-
get
public byte get()
Description copied from interface:PositionedByteRangeRetrieve the next byte from this range.- Specified by:
getin interfacePositionedByteRange
-
get
public PositionedByteRange get(byte[] dst)
Description copied from interface:PositionedByteRangeFilldstwith bytes from the range, starting fromposition. This range'spositionis incremented by the length ofdst, the number of bytes copied.- Specified by:
getin interfacePositionedByteRange- Parameters:
dst- the destination of the copy.- Returns:
- this.
-
get
public PositionedByteRange get(byte[] dst, int offset, int length)
Description copied from interface:PositionedByteRangeFilldstwith bytes from the range, starting from the currentposition.lengthbytes are copied intodst, starting atoffset. This range'spositionis incremented by the number of bytes copied.- Specified by:
getin interfacePositionedByteRange- 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
public abstract PositionedByteRange put(byte val)
Description copied from interface:PositionedByteRangeStorevalat the next position in this range.- Specified by:
putin interfacePositionedByteRange- Parameters:
val- the new value.- Returns:
- this.
-
put
public abstract PositionedByteRange put(byte[] val)
Description copied from interface:PositionedByteRangeStore the content ofvalin this range, starting at the next position.- Specified by:
putin interfacePositionedByteRange- Parameters:
val- the new value.- Returns:
- this.
-
put
public abstract PositionedByteRange put(byte[] val, int offset, int length)
Description copied from interface:PositionedByteRangeStorelengthbytes fromvalinto this range. Bytes fromvalare copied starting atoffsetinto the range, starting at the current position.- Specified by:
putin interfacePositionedByteRange- Parameters:
val- the new value.offset- the offset invalfrom which to start copying.length- the number of bytes to copy fromval.- Returns:
- this.
-
putInt
public abstract PositionedByteRange putInt(int index, int val)
Description copied from interface:ByteRangeStore the int value atindex- Specified by:
putIntin interfaceByteRange- Specified by:
putIntin interfacePositionedByteRange- Specified by:
putIntin classAbstractByteRange- Parameters:
index- the index in the range wherevalis storedval- the value to store- Returns:
- this
-
putLong
public abstract PositionedByteRange putLong(int index, long val)
Description copied from interface:ByteRangeStore the long value atindex- Specified by:
putLongin interfaceByteRange- Specified by:
putLongin interfacePositionedByteRange- Specified by:
putLongin classAbstractByteRange- Parameters:
index- the index in the range wherevalis storedval- the value to store- Returns:
- this
-
putShort
public abstract PositionedByteRange putShort(int index, short val)
Description copied from interface:ByteRangeStore the short value atindex- Specified by:
putShortin interfaceByteRange- Specified by:
putShortin interfacePositionedByteRange- Specified by:
putShortin classAbstractByteRange- Parameters:
index- the index in the range wherevalis storedval- the value to store- Returns:
- this
-
putInt
public abstract PositionedByteRange putInt(int val)
Description copied from interface:PositionedByteRangeStore intvalat the next position in this range.- Specified by:
putIntin interfacePositionedByteRange- Parameters:
val- the new value.- Returns:
- this.
-
putLong
public abstract PositionedByteRange putLong(long val)
Description copied from interface:PositionedByteRangeStore longvalat the next position in this range.- Specified by:
putLongin interfacePositionedByteRange- Parameters:
val- the new value.- Returns:
- this.
-
putShort
public abstract PositionedByteRange putShort(short val)
Description copied from interface:PositionedByteRangeStore shortvalat the next position in this range.- Specified by:
putShortin interfacePositionedByteRange- Parameters:
val- the new value.- Returns:
- this.
-
putVLong
public abstract int putVLong(int index, long val)Description copied from interface:ByteRangeStore the long value atindexas a VLong- Specified by:
putVLongin interfaceByteRange- Specified by:
putVLongin classAbstractByteRange- Parameters:
index- the index in the range wherevalis storedval- the value to store- Returns:
- number of bytes written
-
putVLong
public abstract int putVLong(long val)
Description copied from interface:PositionedByteRangeStore the longvalat the next position as a VLong- Specified by:
putVLongin interfacePositionedByteRange- Parameters:
val- the value to store- Returns:
- number of bytes written
-
get
public PositionedByteRange get(int index, byte[] dst)
Description copied from interface:ByteRangeFilldstwith bytes from the range, starting fromindex.- Specified by:
getin interfaceByteRange- Specified by:
getin interfacePositionedByteRange- Overrides:
getin classAbstractByteRange- Parameters:
index- zero-based index into this range.dst- the destination of the copy.- Returns:
- this.
-
get
public PositionedByteRange get(int index, byte[] dst, int offset, int length)
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 classAbstractByteRange- 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.
-
getShort
public short getShort()
Description copied from interface:PositionedByteRangeRetrieve the next short value from this range.- Specified by:
getShortin interfacePositionedByteRange
-
getInt
public int getInt()
Description copied from interface:PositionedByteRangeRetrieve the next int value from this range.- Specified by:
getIntin interfacePositionedByteRange
-
getLong
public long getLong()
Description copied from interface:PositionedByteRangeRetrieve the next long value from this range.- Specified by:
getLongin interfacePositionedByteRange
-
getVLong
public long getVLong()
Description copied from interface:PositionedByteRangeRetrieve the next long value, which is stored as VLong, from this range- Specified by:
getVLongin interfacePositionedByteRange- Returns:
- the long value which is stored as VLong
-
put
public abstract PositionedByteRange put(int index, byte val)
Description copied from interface:ByteRangeStorevalatindex.- Specified by:
putin interfaceByteRange- Specified by:
putin interfacePositionedByteRange- Specified by:
putin classAbstractByteRange- Parameters:
index- the index in the range wherevalis stored.val- the value to store.- Returns:
- this.
-
put
public abstract PositionedByteRange put(int index, byte[] val)
Description copied from interface:ByteRangeStorevalatindex.- Specified by:
putin interfaceByteRange- Specified by:
putin interfacePositionedByteRange- Specified by:
putin classAbstractByteRange- Parameters:
index- the index in the range wherevalis stored.val- the value to store.- Returns:
- this.
-
put
public abstract PositionedByteRange put(int index, byte[] val, int offset, int length)
Description copied from interface:ByteRangeStorelengthbytes fromvalinto this range, starting atindex. Bytes fromvalare copied starting atoffsetinto the range.- Specified by:
putin interfaceByteRange- Specified by:
putin interfacePositionedByteRange- Specified by:
putin classAbstractByteRange- 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
public abstract PositionedByteRange deepCopy()
Description copied from interface:ByteRangeCreate a newByteRangewith new backing byte[] containing a copy of the content fromthisrange's window.- Specified by:
deepCopyin interfaceByteRange- Specified by:
deepCopyin interfacePositionedByteRange- Returns:
- Deep copy
-
shallowCopy
public abstract PositionedByteRange 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- Specified by:
shallowCopyin interfacePositionedByteRange- Returns:
- new
ByteRangeobject referencing this range's byte[].
-
shallowCopySubRange
public abstract PositionedByteRange shallowCopySubRange(int innerOffset, int copyLength)
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- Specified by:
shallowCopySubRangein interfacePositionedByteRange- 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
public PositionedByteRange setLimit(int limit)
Description copied from interface:PositionedByteRangeLimits the byte range upto a specified value. Limit cannot be greater than capacity- Specified by:
setLimitin interfacePositionedByteRange- Returns:
- PositionedByteRange
-
getLimit
public int getLimit()
Description copied from interface:PositionedByteRangeReturn the current limit- Specified by:
getLimitin interfacePositionedByteRange- Returns:
- limit
-
-