org.apache.hadoop.hbase.regionserver
Class StripeStoreFileManager

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.StripeStoreFileManager
All Implemented Interfaces:
StripeCompactionPolicy.StripeInformationProvider, StoreFileManager

@InterfaceAudience.Private
public class StripeStoreFileManager
extends Object
implements StoreFileManager, StripeCompactionPolicy.StripeInformationProvider

Stripe implementation of StoreFileManager. Not thread safe - relies on external locking (in HStore). Collections that this class returns are immutable or unique to the call, so they should be safe. Stripe store splits the key space of the region into non-overlapping stripes, as well as some recent files that have all the keys (level 0). Each stripe contains a set of files. When L0 is compacted, it's split into the files corresponding to existing stripe boundaries, that can thus be added to stripes. When scan or get happens, it only has to read the files from the corresponding stripes. See StripeCompationPolicy on how the stripes are determined; this class doesn't care. This class should work together with StripeCompactionPolicy and StripeCompactor. With regard to how they work, we make at least the following (reasonable) assumptions: - Compaction produces one file per new stripe (if any); that is easy to change. - Compaction has one contiguous set of stripes both in and out, except if L0 is involved.


Field Summary
static byte[] OPEN_KEY
          The key value used for range boundary, indicating that the boundary is open (i.e.
static byte[] STRIPE_END_KEY
           
static byte[] STRIPE_START_KEY
          The file metadata fields that contain the stripe information.
 
Constructor Summary
StripeStoreFileManager(KeyValue.KVComparator kvComparator, org.apache.hadoop.conf.Configuration conf, StripeStoreConfig config)
           
 
Method Summary
 void addCompactionResults(Collection<StoreFile> compactedFiles, Collection<StoreFile> results)
          Adds compaction results into the structure.
 com.google.common.collect.ImmutableCollection<StoreFile> clearFiles()
          Clears all the files currently in use and returns them.
 Iterator<StoreFile> getCandidateFilesForRowKeyBefore(KeyValue targetKey)
          See StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue) for details on this methods.
 double getCompactionPressure()
           
 byte[] getEndRow(int stripeIndex)
          Gets the end row for a given stripe.
 Collection<StoreFile> getFilesForScanOrGet(boolean isGet, byte[] startRow, byte[] stopRow)
          Gets the store files to scan for a Scan or Get request.
 List<StoreFile> getLevel0Files()
           
 byte[] getSplitPoint()
          Gets the split point for the split of this set of store files (approx.
 byte[] getStartRow(int stripeIndex)
          Gets the start row for a given stripe.
 int getStoreCompactionPriority()
           
 int getStorefileCount()
          Returns the number of files currently in use.
 Collection<StoreFile> getStorefiles()
          Gets the snapshot of the store files currently in use.
 List<byte[]> getStripeBoundaries()
           
 int getStripeCount()
           
 ArrayList<com.google.common.collect.ImmutableList<StoreFile>> getStripes()
           
 Collection<StoreFile> getUnneededFiles(long maxTs, List<StoreFile> filesCompacting)
           
 void insertNewFiles(Collection<StoreFile> sfs)
          Adds new files, either for from MemStore flush or bulk insert, into the structure.
 void loadFiles(List<StoreFile> storeFiles)
          Loads the initial store files into empty StoreFileManager.
 Iterator<StoreFile> updateCandidateFilesForRowKeyBefore(Iterator<StoreFile> candidateFiles, KeyValue targetKey, KeyValue candidate)
          See StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue) and StoreFileManager.updateCandidateFilesForRowKeyBefore(Iterator, KeyValue, KeyValue) for details on this methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRIPE_START_KEY

public static final byte[] STRIPE_START_KEY
The file metadata fields that contain the stripe information.


STRIPE_END_KEY

public static final byte[] STRIPE_END_KEY

OPEN_KEY

public static final byte[] OPEN_KEY
The key value used for range boundary, indicating that the boundary is open (i.e. +-inf).

Constructor Detail

StripeStoreFileManager

public StripeStoreFileManager(KeyValue.KVComparator kvComparator,
                              org.apache.hadoop.conf.Configuration conf,
                              StripeStoreConfig config)
Method Detail

loadFiles

public void loadFiles(List<StoreFile> storeFiles)
Description copied from interface: StoreFileManager
Loads the initial store files into empty StoreFileManager.

Specified by:
loadFiles in interface StoreFileManager
Parameters:
storeFiles - The files to load.

getStorefiles

public Collection<StoreFile> getStorefiles()
Description copied from interface: StoreFileManager
Gets the snapshot of the store files currently in use. Can be used for things like metrics and checks; should not assume anything about relations between store files in the list.

Specified by:
getStorefiles in interface StripeCompactionPolicy.StripeInformationProvider
Specified by:
getStorefiles in interface StoreFileManager
Returns:
The list of StoreFiles.

insertNewFiles

public void insertNewFiles(Collection<StoreFile> sfs)
                    throws IOException
Description copied from interface: StoreFileManager
Adds new files, either for from MemStore flush or bulk insert, into the structure.

Specified by:
insertNewFiles in interface StoreFileManager
Parameters:
sfs - New store files.
Throws:
IOException

clearFiles

public com.google.common.collect.ImmutableCollection<StoreFile> clearFiles()
Description copied from interface: StoreFileManager
Clears all the files currently in use and returns them.

Specified by:
clearFiles in interface StoreFileManager
Returns:
The files previously in use.

getStorefileCount

public int getStorefileCount()
Description copied from interface: StoreFileManager
Returns the number of files currently in use.

Specified by:
getStorefileCount in interface StoreFileManager
Returns:
The number of files.

getCandidateFilesForRowKeyBefore

public Iterator<StoreFile> getCandidateFilesForRowKeyBefore(KeyValue targetKey)
See StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue) for details on this methods.

Specified by:
getCandidateFilesForRowKeyBefore in interface StoreFileManager
Parameters:
targetKey - The key that is the basis of the search.
Returns:
The files that may have the key less than or equal to targetKey, in reverse order of new-ness, and preference for target key.

updateCandidateFilesForRowKeyBefore

public Iterator<StoreFile> updateCandidateFilesForRowKeyBefore(Iterator<StoreFile> candidateFiles,
                                                               KeyValue targetKey,
                                                               KeyValue candidate)
See StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue) and StoreFileManager.updateCandidateFilesForRowKeyBefore(Iterator, KeyValue, KeyValue) for details on this methods.

Specified by:
updateCandidateFilesForRowKeyBefore in interface StoreFileManager
Parameters:
candidateFiles - The candidate files not yet checked for better candidates - return value from StoreFileManager.getCandidateFilesForRowKeyBefore(KeyValue), with some files already removed.
targetKey - The key to search for.
candidate - The current best candidate found.
Returns:
The list to replace candidateFiles.

getSplitPoint

public byte[] getSplitPoint()
                     throws IOException
Description copied from interface: StoreFileManager
Gets the split point for the split of this set of store files (approx. middle).

Specified by:
getSplitPoint in interface StoreFileManager
Returns:
The mid-point, or null if no split is possible.
Throws:
IOException

getFilesForScanOrGet

public Collection<StoreFile> getFilesForScanOrGet(boolean isGet,
                                                  byte[] startRow,
                                                  byte[] stopRow)
Description copied from interface: StoreFileManager
Gets the store files to scan for a Scan or Get request.

Specified by:
getFilesForScanOrGet in interface StoreFileManager
Parameters:
isGet - Whether it's a get.
startRow - Start row of the request.
stopRow - Stop row of the request.
Returns:
The list of files that are to be read for this request.

addCompactionResults

public void addCompactionResults(Collection<StoreFile> compactedFiles,
                                 Collection<StoreFile> results)
                          throws IOException
Description copied from interface: StoreFileManager
Adds compaction results into the structure.

Specified by:
addCompactionResults in interface StoreFileManager
Parameters:
compactedFiles - The input files for the compaction.
results - The resulting files for the compaction.
Throws:
IOException

getStoreCompactionPriority

public int getStoreCompactionPriority()
Specified by:
getStoreCompactionPriority in interface StoreFileManager
Returns:
The store compaction priority.

getStartRow

public final byte[] getStartRow(int stripeIndex)
Description copied from interface: StripeCompactionPolicy.StripeInformationProvider
Gets the start row for a given stripe.

Specified by:
getStartRow in interface StripeCompactionPolicy.StripeInformationProvider
Parameters:
stripeIndex - Stripe index.
Returns:
Start row. May be an open key.

getEndRow

public final byte[] getEndRow(int stripeIndex)
Description copied from interface: StripeCompactionPolicy.StripeInformationProvider
Gets the end row for a given stripe.

Specified by:
getEndRow in interface StripeCompactionPolicy.StripeInformationProvider
Parameters:
stripeIndex - Stripe index.
Returns:
End row. May be an open key.

getLevel0Files

public List<StoreFile> getLevel0Files()
Specified by:
getLevel0Files in interface StripeCompactionPolicy.StripeInformationProvider
Returns:
Level 0 files.

getStripeBoundaries

public List<byte[]> getStripeBoundaries()
Specified by:
getStripeBoundaries in interface StripeCompactionPolicy.StripeInformationProvider
Returns:
All stripe boundaries; including the open ones on both ends.

getStripes

public ArrayList<com.google.common.collect.ImmutableList<StoreFile>> getStripes()
Specified by:
getStripes in interface StripeCompactionPolicy.StripeInformationProvider
Returns:
The stripes.

getStripeCount

public int getStripeCount()
Specified by:
getStripeCount in interface StripeCompactionPolicy.StripeInformationProvider
Returns:
Stripe count.

getUnneededFiles

public Collection<StoreFile> getUnneededFiles(long maxTs,
                                              List<StoreFile> filesCompacting)
Specified by:
getUnneededFiles in interface StoreFileManager
Parameters:
maxTs - Maximum expired timestamp.
filesCompacting - Files that are currently compacting.
Returns:
The files which don't have any necessary data according to TTL and other criteria.

getCompactionPressure

public double getCompactionPressure()
Specified by:
getCompactionPressure in interface StoreFileManager
Returns:
the compaction pressure used for compaction throughput tuning.
See Also:
Store.getCompactionPressure()


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