org.apache.hadoop.hbase.io.hfile
Class HFileReaderV2.AbstractScannerV2

java.lang.Object
  extended by org.apache.hadoop.hbase.io.hfile.AbstractHFileReader.Scanner
      extended by org.apache.hadoop.hbase.io.hfile.HFileReaderV2.AbstractScannerV2
All Implemented Interfaces:
HFileScanner
Direct Known Subclasses:
HFileReaderV2.EncodedScannerV2, HFileReaderV2.ScannerV2
Enclosing class:
HFileReaderV2

protected abstract static class HFileReaderV2.AbstractScannerV2
extends AbstractHFileReader.Scanner


Field Summary
protected  HFileBlock block
           
protected  byte[] nextIndexedKey
          The next indexed key is to keep track of the indexed key of the next data block.
 
Fields inherited from class org.apache.hadoop.hbase.io.hfile.AbstractHFileReader.Scanner
blockBuffer, blockFetches, cacheBlocks, currKeyLen, currMemstoreTS, currMemstoreTSLen, currValueLen, isCompaction, pread, reader
 
Constructor Summary
HFileReaderV2.AbstractScannerV2(HFileReaderV2 r, boolean cacheBlocks, boolean pread, boolean isCompaction)
           
 
Method Summary
abstract  int compareKey(KeyValue.KVComparator comparator, byte[] key, int offset, int length)
          Compare the given key against the current key
protected abstract  ByteBuffer getFirstKeyInBlock(HFileBlock curBlock)
           
 byte[] getNextIndexedKey()
           
protected abstract  int loadBlockAndSeekToKey(HFileBlock seekToBlock, byte[] nextIndexedKey, boolean rewind, byte[] key, int offset, int length, boolean seekBefore)
           
protected  HFileBlock readNextDataBlock()
          Scans blocks in the "scanned" section of the HFile until the next data block is found.
 int reseekTo(byte[] key, int offset, int length)
           
 boolean seekBefore(byte[] key, int offset, int length)
           
 int seekTo(byte[] key, int offset, int length)
           
protected  int seekTo(byte[] key, int offset, int length, boolean rewind)
          An internal API function.
 
Methods inherited from class org.apache.hadoop.hbase.io.hfile.AbstractHFileReader.Scanner
assertSeeked, getReader, isSeeked, reseekTo, seekBefore, seekTo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hbase.io.hfile.HFileScanner
getKey, getKeyString, getKeyValue, getValue, getValueString, next, seekTo
 

Field Detail

block

protected HFileBlock block

nextIndexedKey

protected byte[] nextIndexedKey
The next indexed key is to keep track of the indexed key of the next data block. If the nextIndexedKey is HConstants.NO_NEXT_INDEXED_KEY, it means that the current data block is the last data block. If the nextIndexedKey is null, it means the nextIndexedKey has not been loaded yet.

Constructor Detail

HFileReaderV2.AbstractScannerV2

public HFileReaderV2.AbstractScannerV2(HFileReaderV2 r,
                                       boolean cacheBlocks,
                                       boolean pread,
                                       boolean isCompaction)
Method Detail

getNextIndexedKey

public byte[] getNextIndexedKey()
Returns:
the next key in the index (the key to seek to the next block)

seekTo

protected int seekTo(byte[] key,
                     int offset,
                     int length,
                     boolean rewind)
              throws IOException
An internal API function. Seek to the given key, optionally rewinding to the first key of the block before doing the seek.

Parameters:
key - key byte array
offset - key offset in the key byte array
length - key length
rewind - whether to rewind to the first key of the block before doing the seek. If this is false, we are assuming we never go back, otherwise the result is undefined.
Returns:
-1 if the key is earlier than the first key of the file, 0 if we are at the given key, 1 if we are past the given key -2 if the key is earlier than the first key of the file while using a faked index key
Throws:
IOException

getFirstKeyInBlock

protected abstract ByteBuffer getFirstKeyInBlock(HFileBlock curBlock)

loadBlockAndSeekToKey

protected abstract int loadBlockAndSeekToKey(HFileBlock seekToBlock,
                                             byte[] nextIndexedKey,
                                             boolean rewind,
                                             byte[] key,
                                             int offset,
                                             int length,
                                             boolean seekBefore)
                                      throws IOException
Throws:
IOException

seekTo

public int seekTo(byte[] key,
                  int offset,
                  int length)
           throws IOException
Throws:
IOException

reseekTo

public int reseekTo(byte[] key,
                    int offset,
                    int length)
             throws IOException
Throws:
IOException

seekBefore

public boolean seekBefore(byte[] key,
                          int offset,
                          int length)
                   throws IOException
Throws:
IOException

readNextDataBlock

protected HFileBlock readNextDataBlock()
                                throws IOException
Scans blocks in the "scanned" section of the HFile until the next data block is found.

Returns:
the next block, or null if there are no more data blocks
Throws:
IOException

compareKey

public abstract 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 © 2007–2016 The Apache Software Foundation. All rights reserved.