org.apache.hadoop.hbase.regionserver
Class StoreScanner

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

@InterfaceAudience.Private
public class StoreScanner
extends NonLazyKeyValueScanner
implements KeyValueScanner, InternalScanner, ChangedReadersObserver

Scanner scans both the memstore and the Store. Coalesce KeyValue stream into List for a single row.


Field Summary
protected  boolean cacheBlocks
           
protected  boolean closing
           
protected  NavigableSet<byte[]> columns
           
protected  int countPerRow
           
protected  ExecutorService executor
           
protected  boolean explicitColumnQuery
           
protected  KeyValueHeap heap
           
protected  boolean isGet
           
protected  boolean isParallelSeekEnabled
          A flag that enables StoreFileScanner parallel-seeking
protected  KeyValue lastTop
           
protected static boolean lazySeekEnabledGlobally
          Used during unit testing to ensure that lazy seek does save seek ops
protected  ScanQueryMatcher matcher
           
protected  int minVersions
           
protected  long oldestUnexpiredTS
           
protected  Scan scan
           
protected  Store store
           
protected  int storeLimit
           
protected  int storeOffset
           
static String STORESCANNER_PARALLEL_SEEK_ENABLE
           
protected  boolean useRowColBloom
           
 
Constructor Summary
protected StoreScanner(Store store, boolean cacheBlocks, Scan scan, NavigableSet<byte[]> columns, long ttl, int minVersions)
          An internal constructor.
  StoreScanner(Store store, ScanInfo scanInfo, Scan scan, List<? extends KeyValueScanner> scanners, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow)
          Used for compactions that drop deletes from a limited range of rows.
  StoreScanner(Store store, ScanInfo scanInfo, Scan scan, List<? extends KeyValueScanner> scanners, ScanType scanType, long smallestReadPoint, long earliestPutTs)
          Used for compactions.
  StoreScanner(Store store, ScanInfo scanInfo, Scan scan, NavigableSet<byte[]> columns)
          Opens a scanner across memstore, snapshot, and all StoreFiles.
 
Method Summary
protected  boolean checkReseek()
           
 void close()
          Close the KeyValue scanner.
 long getEstimatedNumberOfKvsScanned()
           
protected  List<KeyValueScanner> getScannersNoCompaction()
          Get a filtered list of scanners.
 long getSequenceID()
          Get the sequence id associated with this KeyValueScanner.
 KeyValue next()
          Return the next KeyValue in this scanner, iterating the scanner
 boolean next(List<KeyValue> outResult)
          Grab the next row's worth of values.
 boolean next(List<KeyValue> outResult, int limit)
          Get the next row of values from this Store.
 KeyValue peek()
          Look at the next KeyValue in this scanner, but do not iterate scanner.
 boolean reseek(KeyValue kv)
          Reseek the scanner at or after the specified KeyValue.
protected  void resetScannerStack(KeyValue lastTopKey)
           
 boolean seek(KeyValue key)
          Seek the scanner at or after the specified KeyValue.
protected  List<KeyValueScanner> selectScannersFrom(List<? extends KeyValueScanner> allScanners)
          Filters the given list of scanners using Bloom filter, time range, and TTL.
 void updateReaders()
          Notify observers.
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.NonLazyKeyValueScanner
doRealSeek, enforceSeek, isFileScanner, realSeekDone, requestSeek, 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, requestSeek, shouldUseScanner
 

Field Detail

store

protected Store store

matcher

protected ScanQueryMatcher matcher

heap

protected KeyValueHeap heap

cacheBlocks

protected boolean cacheBlocks

countPerRow

protected int countPerRow

storeLimit

protected int storeLimit

storeOffset

protected int storeOffset

closing

protected boolean closing

isGet

protected final boolean isGet

explicitColumnQuery

protected final boolean explicitColumnQuery

useRowColBloom

protected final boolean useRowColBloom

isParallelSeekEnabled

protected boolean isParallelSeekEnabled
A flag that enables StoreFileScanner parallel-seeking


executor

protected ExecutorService executor

scan

protected final Scan scan

columns

protected final NavigableSet<byte[]> columns

oldestUnexpiredTS

protected final long oldestUnexpiredTS

minVersions

protected final int minVersions

STORESCANNER_PARALLEL_SEEK_ENABLE

public static final String STORESCANNER_PARALLEL_SEEK_ENABLE
See Also:
Constant Field Values

lazySeekEnabledGlobally

protected static boolean lazySeekEnabledGlobally
Used during unit testing to ensure that lazy seek does save seek ops


lastTop

protected KeyValue lastTop
Constructor Detail

StoreScanner

protected StoreScanner(Store store,
                       boolean cacheBlocks,
                       Scan scan,
                       NavigableSet<byte[]> columns,
                       long ttl,
                       int minVersions)
An internal constructor.


StoreScanner

public StoreScanner(Store store,
                    ScanInfo scanInfo,
                    Scan scan,
                    NavigableSet<byte[]> columns)
             throws IOException
Opens a scanner across memstore, snapshot, and all StoreFiles. Assumes we are not in a compaction.

Parameters:
store - who we scan
scan - the spec
columns - which columns we are scanning
Throws:
IOException

StoreScanner

public StoreScanner(Store store,
                    ScanInfo scanInfo,
                    Scan scan,
                    List<? extends KeyValueScanner> scanners,
                    ScanType scanType,
                    long smallestReadPoint,
                    long earliestPutTs)
             throws IOException
Used for compactions.

Opens a scanner across specified StoreFiles.

Parameters:
store - who we scan
scan - the spec
scanners - ancillary scanners
smallestReadPoint - the readPoint that we should use for tracking versions
Throws:
IOException

StoreScanner

public StoreScanner(Store store,
                    ScanInfo scanInfo,
                    Scan scan,
                    List<? extends KeyValueScanner> scanners,
                    long smallestReadPoint,
                    long earliestPutTs,
                    byte[] dropDeletesFromRow,
                    byte[] dropDeletesToRow)
             throws IOException
Used for compactions that drop deletes from a limited range of rows.

Opens a scanner across specified StoreFiles.

Parameters:
store - who we scan
scan - the spec
scanners - ancillary scanners
smallestReadPoint - the readPoint that we should use for tracking versions
dropDeletesFromRow - The inclusive left bound of the range; can be EMPTY_START_ROW.
dropDeletesToRow - The exclusive right bound of the range; can be EMPTY_END_ROW.
Throws:
IOException
Method Detail

getScannersNoCompaction

protected List<KeyValueScanner> getScannersNoCompaction()
                                                 throws IOException
Get a filtered list of scanners. Assumes we are not in a compaction.

Returns:
list of scanners to seek
Throws:
IOException

selectScannersFrom

protected List<KeyValueScanner> selectScannersFrom(List<? extends KeyValueScanner> allScanners)
Filters the given list of scanners using Bloom filter, time range, and TTL.


peek

public KeyValue peek()
Description copied from interface: KeyValueScanner
Look at the next KeyValue in this scanner, but do not iterate scanner.

Specified by:
peek in interface KeyValueScanner
Returns:
the next KeyValue

next

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

Specified by:
next in interface KeyValueScanner
Returns:
the next KeyValue

close

public void close()
Description copied from interface: KeyValueScanner
Close the KeyValue scanner.

Specified by:
close in interface Closeable
Specified by:
close in interface InternalScanner
Specified by:
close in interface KeyValueScanner

seek

public boolean seek(KeyValue key)
             throws IOException
Description copied from interface: KeyValueScanner
Seek the scanner at or after the specified KeyValue.

Specified by:
seek in interface KeyValueScanner
Parameters:
key - seek value
Returns:
true if scanner has values left, false if end of scanner
Throws:
IOException

next

public boolean next(List<KeyValue> outResult,
                    int limit)
             throws IOException
Get the next row of values from this Store.

Specified by:
next in interface InternalScanner
Parameters:
outResult -
limit -
Returns:
true if there are more rows, false if scanner is done
Throws:
IOException - e

next

public boolean next(List<KeyValue> outResult)
             throws IOException
Description copied from interface: InternalScanner
Grab the next row's worth of values.

Specified by:
next in interface InternalScanner
Parameters:
outResult - return output array
Returns:
true if more rows exist after this one, false if scanner is done
Throws:
IOException - e

updateReaders

public void updateReaders()
                   throws IOException
Description copied from interface: ChangedReadersObserver
Notify observers.

Specified by:
updateReaders in interface ChangedReadersObserver
Throws:
IOException - e

checkReseek

protected boolean checkReseek()
                       throws IOException
Returns:
true if top of heap has changed (and KeyValueHeap has to try the next KV)
Throws:
IOException

resetScannerStack

protected void resetScannerStack(KeyValue lastTopKey)
                          throws IOException
Throws:
IOException

reseek

public boolean reseek(KeyValue kv)
               throws IOException
Description copied from interface: KeyValueScanner
Reseek the scanner at or after the specified KeyValue. This method is guaranteed to seek at or after the required key only if the key comes after the current position of the scanner. Should not be used to seek to a key which may come before the current position.

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

getSequenceID

public long getSequenceID()
Description copied from interface: KeyValueScanner
Get the sequence id associated with this KeyValueScanner. This is required for comparing multiple files to find out which one has the latest data. The default implementation for this would be to return 0. A file having lower sequence id will be considered to be the older one.

Specified by:
getSequenceID in interface KeyValueScanner

getEstimatedNumberOfKvsScanned

public long getEstimatedNumberOfKvsScanned()
Returns:
The estimated number of KVs seen by this scanner (includes some skipped KVs).


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