org.apache.hadoop.hbase.util
Interface PositionedByteRange

All Superinterfaces:
ByteRange, Comparable<ByteRange>
All Known Implementing Classes:
SimplePositionedByteRange

@InterfaceAudience.Public
@InterfaceStability.Evolving
public interface PositionedByteRange
extends ByteRange

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
 PositionedByteRange deepCopy()
          Create a new ByteRange with new backing byte[] containing a copy of the content from this range's window.
 byte get()
          Retrieve the next byte from this range.
 PositionedByteRange get(byte[] dst)
          Fill dst with bytes from the range, starting from position.
 PositionedByteRange get(byte[] dst, int offset, int length)
          Fill dst with bytes from the range, starting from the current position.
 PositionedByteRange get(int index, byte[] dst)
          Fill dst with bytes from the range, starting from index.
 PositionedByteRange get(int index, byte[] dst, int offset, int length)
          Fill dst with bytes from the range, starting from index.
 int getPosition()
          The current position marker.
 int getRemaining()
          The number of bytes remaining between position and the end of the range.
 byte peek()
          Retrieve the next byte from this range without incrementing position.
 PositionedByteRange put(byte val)
          Store val at the next position in this range.
 PositionedByteRange put(byte[] val)
          Store the content of val in this range, starting at the next position.
 PositionedByteRange put(byte[] val, int offset, int length)
          Store length bytes from val into this range.
 PositionedByteRange put(int index, byte val)
          Store val at index.
 PositionedByteRange put(int index, byte[] val)
          Store val at index.
 PositionedByteRange put(int index, byte[] val, int offset, int length)
          Store length bytes from val into this range, starting at index.
 PositionedByteRange set(byte[] bytes)
          Reuse this ByteRange over a new byte[].
 PositionedByteRange set(byte[] bytes, int offset, int length)
          Reuse this ByteRange over a new byte[].
 PositionedByteRange set(int capacity)
          Reuse this ByteRange over a new byte[].
 PositionedByteRange setLength(int length)
          Update the length of this range.
 PositionedByteRange setOffset(int offset)
          Update the beginning of this range.
 PositionedByteRange setPosition(int position)
          Update the position index.
 PositionedByteRange shallowCopy()
          Create a new ByteRange that points at this range's byte[].
 PositionedByteRange shallowCopySubRange(int innerOffset, int copyLength)
          Create a new ByteRange that points at this range's byte[].
 PositionedByteRange unset()
          Nullifies this ByteRange.
 
Methods inherited from interface org.apache.hadoop.hbase.util.ByteRange
deepCopySubRangeTo, deepCopyTo, deepCopyToNewArray, get, getBytes, getLength, getOffset, isEmpty
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getPosition

int getPosition()
The current position marker. This valuae is 0-indexed, relative to the beginning of the range.


setPosition

PositionedByteRange setPosition(int position)
Update the position index. May not be greater than length.

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.


get

PositionedByteRange get(byte[] dst)
Fill dst with bytes from the range, starting from position. This range's position is incremented by the length of dst, the number of bytes copied.

Parameters:
dst - the destination of the copy.
Returns:
this.

get

PositionedByteRange get(byte[] dst,
                        int offset,
                        int length)
Fill dst with bytes from the range, starting from the current position. length bytes are copied into dst, starting at offset. This range's position is incremented by the number of bytes copied.

Parameters:
dst - the destination of the copy.
offset - the offset into dst to start the copy.
length - the number of bytes to copy into dst.
Returns:
this.

put

PositionedByteRange put(byte val)
Store val at the next position in this range.

Parameters:
val - the new value.
Returns:
this.

put

PositionedByteRange put(byte[] val)
Store the content of val in this range, starting at the next position.

Parameters:
val - the new value.
Returns:
this.

put

PositionedByteRange put(byte[] val,
                        int offset,
                        int length)
Store length bytes from val into this range. Bytes from val are copied starting at offset into the range, starting at the current position.

Parameters:
val - the new value.
offset - the offset in val from which to start copying.
length - the number of bytes to copy from val.
Returns:
this.

unset

PositionedByteRange unset()
Description copied from interface: ByteRange
Nullifies this ByteRange. That is, it becomes a husk, being a range over no byte[] whatsoever.

Specified by:
unset in interface ByteRange
Returns:
this

set

PositionedByteRange set(int capacity)
Description copied from interface: ByteRange
Reuse this ByteRange over a new byte[]. offset is set to 0 and length is set to capacity.

Specified by:
set in interface ByteRange
Parameters:
capacity - the size of a new byte[].
Returns:
this

set

PositionedByteRange set(byte[] bytes)
Description copied from interface: ByteRange
Reuse this ByteRange over a new byte[]. offset is set to 0 and length is set to bytes.length. A null bytes IS supported, in which case this method will behave equivalently to ByteRange.unset().

Specified by:
set in interface ByteRange
Parameters:
bytes - the array to wrap.
Returns:
this

set

PositionedByteRange set(byte[] bytes,
                        int offset,
                        int length)
Description copied from interface: ByteRange
Reuse this ByteRange over a new byte[]. A null bytes IS supported, in which case this method will behave equivalently to ByteRange.unset(), regardless of the values of offset and length.

Specified by:
set in interface ByteRange
Parameters:
bytes - The array to wrap.
offset - The offset into bytes considered the beginning of this range.
length - The length of this range.
Returns:
this.

setOffset

PositionedByteRange setOffset(int offset)
Description copied from interface: ByteRange
Update the beginning of this range. offset + length may not be greater than bytes.length.

Specified by:
setOffset in interface ByteRange
Parameters:
offset - the new start of this range.
Returns:
this.

setLength

PositionedByteRange setLength(int length)
Description copied from interface: ByteRange
Update the length of this range. offset + length should not be greater than bytes.length.

Specified by:
setLength in interface ByteRange
Parameters:
length - The new length of this range.
Returns:
this.

get

PositionedByteRange get(int index,
                        byte[] dst)
Description copied from interface: ByteRange
Fill dst with bytes from the range, starting from index.

Specified by:
get in interface ByteRange
Parameters:
index - zero-based index into this range.
dst - the destination of the copy.
Returns:
this.

get

PositionedByteRange get(int index,
                        byte[] dst,
                        int offset,
                        int length)
Description copied from interface: ByteRange
Fill dst with bytes from the range, starting from index. length bytes are copied into dst, starting at offset.

Specified by:
get in interface ByteRange
Parameters:
index - zero-based index into this range.
dst - the destination of the copy.
offset - the offset into dst to start the copy.
length - the number of bytes to copy into dst.
Returns:
this.

put

PositionedByteRange put(int index,
                        byte val)
Description copied from interface: ByteRange
Store val at index.

Specified by:
put in interface ByteRange
Parameters:
index - the index in the range where val is stored.
val - the value to store.
Returns:
this.

put

PositionedByteRange put(int index,
                        byte[] val)
Description copied from interface: ByteRange
Store val at index.

Specified by:
put in interface ByteRange
Parameters:
index - the index in the range where val is stored.
val - the value to store.
Returns:
this.

put

PositionedByteRange put(int index,
                        byte[] val,
                        int offset,
                        int length)
Description copied from interface: ByteRange
Store length bytes from val into this range, starting at index. Bytes from val are copied starting at offset into the range.

Specified by:
put in interface ByteRange
Parameters:
index - position in this range to start the copy.
val - the value to store.
offset - the offset in val from which to start copying.
length - the number of bytes to copy from val.
Returns:
this.

deepCopy

PositionedByteRange deepCopy()
Description copied from interface: ByteRange
Create a new ByteRange with new backing byte[] containing a copy of the content from this range's window.

Specified by:
deepCopy in interface ByteRange
Returns:
Deep copy

shallowCopy

PositionedByteRange shallowCopy()
Description copied from interface: ByteRange
Create a new ByteRange 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 interface ByteRange
Returns:
new ByteRange object referencing this range's byte[].

shallowCopySubRange

PositionedByteRange shallowCopySubRange(int innerOffset,
                                        int copyLength)
Description copied from interface: ByteRange
Create a new ByteRange 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 interface ByteRange
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[].


Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.