org.apache.hadoop.hbase.regionserver
Class ReversedKeyValueHeap

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.NonLazyKeyValueScanner
      extended by org.apache.hadoop.hbase.regionserver.NonReversedNonLazyKeyValueScanner
          extended by org.apache.hadoop.hbase.regionserver.KeyValueHeap
              extended by org.apache.hadoop.hbase.regionserver.ReversedKeyValueHeap
All Implemented Interfaces:
Closeable, InternalScanner, KeyValueScanner

@InterfaceAudience.Private
public class ReversedKeyValueHeap
extends KeyValueHeap

ReversedKeyValueHeap is used for supporting reversed scanning. Compared with KeyValueHeap, its scanner comparator is a little different (see ReversedKVScannerComparator), all seek is backward seek(see KeyValueScanner.backwardSeek(org.apache.hadoop.hbase.KeyValue)), and it will jump to the previous row if it is already at the end of one row when calling next().


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.regionserver.KeyValueHeap
KeyValueHeap.KVScannerComparator
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.KeyValueHeap
comparator, current, heap
 
Constructor Summary
ReversedKeyValueHeap(List<? extends KeyValueScanner> scanners, KeyValue.KVComparator comparator)
           
 
Method Summary
 boolean backwardSeek(KeyValue seekKey)
          Seek the scanner at or before the row of specified KeyValue, it firstly tries to seek the scanner at or after the specified KeyValue, return if peek KeyValue of scanner has the same row with specified KeyValue, otherwise seek the scanner at the first KeyValue of the row which is the previous row of specified KeyValue
 KeyValue next()
          Return the next KeyValue in this scanner, iterating the scanner
 boolean requestSeek(KeyValue key, boolean forward, boolean useBloom)
          Similar to KeyValueScanner.seek(org.apache.hadoop.hbase.KeyValue) (or KeyValueScanner.reseek(org.apache.hadoop.hbase.KeyValue) if forward is true) but only does a seek operation after checking that it is really necessary for the row/column combination specified by the kv parameter.
 boolean reseek(KeyValue seekKey)
          This function is identical to the KeyValueHeap.seek(KeyValue) function except that scanner.seek(seekKey) is changed to scanner.reseek(seekKey).
 boolean seek(KeyValue seekKey)
          Seeks all scanners at or below the specified seek key.
 boolean seekToLastRow()
          Seek the scanner at the first KeyValue of last row
 boolean seekToPreviousRow(KeyValue seekKey)
          Seek the scanner at the first KeyValue of the row which is the previous row of specified key
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.KeyValueHeap
close, getHeap, getNextIndexedKey, getSequenceID, next, next, peek, pollRealKV
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.NonLazyKeyValueScanner
doRealSeek, enforceSeek, isFileScanner, realSeekDone, shouldUseScanner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hbase.regionserver.KeyValueScanner
enforceSeek, isFileScanner, realSeekDone, shouldUseScanner
 

Constructor Detail

ReversedKeyValueHeap

public ReversedKeyValueHeap(List<? extends KeyValueScanner> scanners,
                            KeyValue.KVComparator comparator)
                     throws IOException
Parameters:
scanners -
comparator -
Throws:
IOException
Method Detail

seek

public boolean seek(KeyValue seekKey)
             throws IOException
Description copied from class: KeyValueHeap
Seeks all scanners at or below the specified seek key. If we earlied-out of a row, we may end up skipping values that were never reached yet. Rather than iterating down, we want to give the opportunity to re-seek.

As individual scanners may run past their ends, those scanners are automatically closed and removed from the heap.

This function (and KeyValueHeap.reseek(KeyValue)) does not do multi-column Bloom filter and lazy-seek optimizations. To enable those, call KeyValueHeap.requestSeek(KeyValue, boolean, boolean).

Specified by:
seek in interface KeyValueScanner
Overrides:
seek in class KeyValueHeap
Parameters:
seekKey - KeyValue to seek at or after
Returns:
true if KeyValues exist at or after specified key, false if not
Throws:
IOException

reseek

public boolean reseek(KeyValue seekKey)
               throws IOException
Description copied from class: KeyValueHeap
This function is identical to the KeyValueHeap.seek(KeyValue) function except that scanner.seek(seekKey) is changed to scanner.reseek(seekKey).

Specified by:
reseek in interface KeyValueScanner
Overrides:
reseek in class KeyValueHeap
Parameters:
seekKey - seek value (should be non-null)
Returns:
true if scanner has values left, false if end of scanner
Throws:
IOException

requestSeek

public boolean requestSeek(KeyValue key,
                           boolean forward,
                           boolean useBloom)
                    throws IOException
Description copied from class: KeyValueHeap
Similar to KeyValueScanner.seek(org.apache.hadoop.hbase.KeyValue) (or KeyValueScanner.reseek(org.apache.hadoop.hbase.KeyValue) if forward is true) but only does a seek operation after checking that it is really necessary for the row/column combination specified by the kv parameter. This function was added to avoid unnecessary disk seeks by checking row-column Bloom filters before a seek on multi-column get/scan queries, and to optimize by looking up more recent files first.

Specified by:
requestSeek in interface KeyValueScanner
Overrides:
requestSeek in class KeyValueHeap
forward - do a forward-only "reseek" instead of a random-access seek
useBloom - whether to enable multi-column Bloom filter optimization
Throws:
IOException

seekToPreviousRow

public boolean seekToPreviousRow(KeyValue seekKey)
                          throws IOException
Description copied from interface: KeyValueScanner
Seek the scanner at the first KeyValue of the row which is the previous row of specified key

Specified by:
seekToPreviousRow in interface KeyValueScanner
Overrides:
seekToPreviousRow in class NonReversedNonLazyKeyValueScanner
Parameters:
seekKey - seek value
Returns:
true if the scanner at the first valid KeyValue of previous row, false if not existing such KeyValue
Throws:
IOException

backwardSeek

public boolean backwardSeek(KeyValue seekKey)
                     throws IOException
Description copied from interface: KeyValueScanner
Seek the scanner at or before the row of specified KeyValue, it firstly tries to seek the scanner at or after the specified KeyValue, return if peek KeyValue of scanner has the same row with specified KeyValue, otherwise seek the scanner at the first KeyValue of the row which is the previous row of specified KeyValue

Specified by:
backwardSeek in interface KeyValueScanner
Overrides:
backwardSeek in class NonReversedNonLazyKeyValueScanner
Parameters:
seekKey - seek KeyValue
Returns:
true if the scanner is at the valid KeyValue, false if such KeyValue does not exist
Throws:
IOException

next

public KeyValue next()
              throws IOException
Description copied from interface: KeyValueScanner
Return the next KeyValue in this scanner, iterating the scanner

Specified by:
next in interface KeyValueScanner
Overrides:
next in class KeyValueHeap
Returns:
the next KeyValue
Throws:
IOException

seekToLastRow

public boolean seekToLastRow()
                      throws IOException
Description copied from interface: KeyValueScanner
Seek the scanner at the first KeyValue of last row

Specified by:
seekToLastRow in interface KeyValueScanner
Overrides:
seekToLastRow in class NonReversedNonLazyKeyValueScanner
Returns:
true if scanner has values left, false if the underlying data is empty
Throws:
IOException


Copyright © 2015 The Apache Software Foundation. All rights reserved.