org.apache.hadoop.hbase.io.encoding
Interface DataBlockEncoder.EncodedSeeker

Enclosing interface:
DataBlockEncoder

public static interface DataBlockEncoder.EncodedSeeker

An interface which enable to seek while underlying data is encoded. It works on one HFileBlock, but it is reusable. See setCurrentBuffer(ByteBuffer).


Method Summary
 int compareKey(KeyValue.KVComparator comparator, byte[] key, int offset, int length)
          Compare the given key against the current key
 ByteBuffer getKeyDeepCopy()
          Does a deep copy of the key at the current position.
 KeyValue getKeyValue()
           
 ByteBuffer getKeyValueBuffer()
           
 ByteBuffer getValueShallowCopy()
          Does a shallow copy of the value at the current position.
 boolean next()
          Move to next position
 void rewind()
          Set position to beginning of given block
 int seekToKeyInBlock(byte[] key, int offset, int length, boolean seekBefore)
          Moves the seeker position within the current block to: the last key that that is less than or equal to the given key if seekBefore is false the last key that is strictly less than the given key if seekBefore is true.
 void setCurrentBuffer(ByteBuffer buffer)
          Set on which buffer there will be done seeking.
 

Method Detail

setCurrentBuffer

void setCurrentBuffer(ByteBuffer buffer)
Set on which buffer there will be done seeking.

Parameters:
buffer - Used for seeking.

getKeyDeepCopy

ByteBuffer getKeyDeepCopy()
Does a deep copy of the key at the current position. A deep copy is necessary because buffers are reused in the decoder.

Returns:
key at current position

getValueShallowCopy

ByteBuffer getValueShallowCopy()
Does a shallow copy of the value at the current position. A shallow copy is possible because the returned buffer refers to the backing array of the original encoded buffer.

Returns:
value at current position

getKeyValueBuffer

ByteBuffer getKeyValueBuffer()
Returns:
key value at current position with position set to limit

getKeyValue

KeyValue getKeyValue()
Returns:
the KeyValue object at the current position. Includes memstore timestamp.

rewind

void rewind()
Set position to beginning of given block


next

boolean next()
Move to next position

Returns:
true on success, false if there is no more positions.

seekToKeyInBlock

int seekToKeyInBlock(byte[] key,
                     int offset,
                     int length,
                     boolean seekBefore)
Moves the seeker position within the current block to:

Parameters:
key - byte array containing the key
offset - key position the array
length - key length in bytes
seekBefore - find the key strictly less than the given key in case of an exact match. Does not matter in case of an inexact match.
Returns:
0 on exact match, 1 on inexact match.

compareKey

int compareKey(KeyValue.KVComparator comparator,
               byte[] key,
               int offset,
               int length)
Compare the given key against the current key

Parameters:
comparator -
key -
offset -
length -
Returns:
-1 is the passed key is smaller than the current key, 0 if equal and 1 if greater


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