org.apache.hadoop.hbase.io
Class HalfStoreFileReader

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.StoreFile.Reader
      extended by org.apache.hadoop.hbase.io.HalfStoreFileReader

@InterfaceAudience.Private
public class HalfStoreFileReader
extends StoreFile.Reader

A facade for a HFile.Reader that serves up either the top or bottom half of a HFile where 'bottom' is the first half of the file containing the keys that sort lowest and 'top' is the second half of the file with keys that sort greater than those of the bottom half. The top includes the split files midkey, of the key that follows if it does not exist in the file.

This type works in tandem with the Reference type. This class is used reading while Reference is used writing.

This file is not splitable. Calls to midkey() return null.


Field Summary
protected  byte[] splitkey
           
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.StoreFile.Reader
bloomFilterType, deleteFamilyBloomFilter, generalBloomFilter, sequenceID, timeRangeTracker
 
Constructor Summary
HalfStoreFileReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p, CacheConfig cacheConf, Reference r, org.apache.hadoop.conf.Configuration conf)
          Creates a half file reader for a normal hfile.
HalfStoreFileReader(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path p, FSDataInputStreamWrapper in, long size, CacheConfig cacheConf, Reference r, org.apache.hadoop.conf.Configuration conf)
          Creates a half file reader for a hfile referred to by an hfilelink.
 
Method Summary
 long getEntries()
           
 long getFilterEntries()
          The number of Bloom filter entries in this store file, or an estimate thereof, if the Bloom filter is not loaded.
 byte[] getFirstKey()
           
 byte[] getLastKey()
           
 HFileScanner getScanner(boolean cacheBlocks, boolean pread, boolean isCompaction)
          Warning: Do not write further code which depends on this call.
protected  boolean isTop()
           
 byte[] midkey()
           
 boolean passesKeyRangeFilter(Scan scan)
          Checks whether the given scan rowkey range overlaps with the current storefile's
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.StoreFile.Reader
close, getBloomFilterType, getComparator, getDeleteFamilyCnt, getHFileMinorVersion, getHFileReader, getHFileVersion, getLastRowKey, getMaxTimestamp, getScanner, getSequenceID, getStoreFileScanner, getStoreFileScanner, getTotalBloomSize, getTotalUncompressedBytes, indexSize, isBulkLoaded, length, loadBloomfilter, loadFileInfo, passesDeleteFamilyBloomFilter, passesGeneralBloomFilter, setBulkLoaded, setDeleteFamilyBloomFilterFaulty, setGeneralBloomFilterFaulty, setSequenceID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

splitkey

protected final byte[] splitkey
Constructor Detail

HalfStoreFileReader

public HalfStoreFileReader(org.apache.hadoop.fs.FileSystem fs,
                           org.apache.hadoop.fs.Path p,
                           CacheConfig cacheConf,
                           Reference r,
                           org.apache.hadoop.conf.Configuration conf)
                    throws IOException
Creates a half file reader for a normal hfile.

Parameters:
fs - fileystem to read from
p - path to hfile
cacheConf -
r - original reference file (contains top or bottom)
conf - Configuration
Throws:
IOException

HalfStoreFileReader

public HalfStoreFileReader(org.apache.hadoop.fs.FileSystem fs,
                           org.apache.hadoop.fs.Path p,
                           FSDataInputStreamWrapper in,
                           long size,
                           CacheConfig cacheConf,
                           Reference r,
                           org.apache.hadoop.conf.Configuration conf)
                    throws IOException
Creates a half file reader for a hfile referred to by an hfilelink.

Parameters:
fs - fileystem to read from
p - path to hfile
in - FSDataInputStreamWrapper
size - Full size of the hfile file
cacheConf -
r - original reference file (contains top or bottom)
conf - Configuration
Throws:
IOException
Method Detail

isTop

protected boolean isTop()

getScanner

public HFileScanner getScanner(boolean cacheBlocks,
                               boolean pread,
                               boolean isCompaction)
Description copied from class: StoreFile.Reader
Warning: Do not write further code which depends on this call. Instead use getStoreFileScanner() which uses the StoreFileScanner class/interface which is the preferred way to scan a store with higher level concepts.

Overrides:
getScanner in class StoreFile.Reader
Parameters:
cacheBlocks - should we cache the blocks?
pread - use pread (for concurrent small readers)
isCompaction - is scanner being used for compaction?
Returns:
the underlying HFileScanner

passesKeyRangeFilter

public boolean passesKeyRangeFilter(Scan scan)
Description copied from class: StoreFile.Reader
Checks whether the given scan rowkey range overlaps with the current storefile's

Overrides:
passesKeyRangeFilter in class StoreFile.Reader
Parameters:
scan - the scan specification. Used to determine the rowkey range.
Returns:
true if there is overlap, false otherwise

getLastKey

public byte[] getLastKey()
Overrides:
getLastKey in class StoreFile.Reader

midkey

public byte[] midkey()
              throws IOException
Overrides:
midkey in class StoreFile.Reader
Throws:
IOException

getFirstKey

public byte[] getFirstKey()
Overrides:
getFirstKey in class StoreFile.Reader

getEntries

public long getEntries()
Overrides:
getEntries in class StoreFile.Reader

getFilterEntries

public long getFilterEntries()
Description copied from class: StoreFile.Reader
The number of Bloom filter entries in this store file, or an estimate thereof, if the Bloom filter is not loaded. This always returns an upper bound of the number of Bloom filter entries.

Overrides:
getFilterEntries in class StoreFile.Reader
Returns:
an estimate of the number of Bloom filter entries in this file


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