org.apache.hadoop.hbase.regionserver.compactions
Class RatioBasedCompactionPolicy

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.compactions.CompactionPolicy
      extended by org.apache.hadoop.hbase.regionserver.compactions.RatioBasedCompactionPolicy
Direct Known Subclasses:
DateTieredCompactionPolicy, ExploringCompactionPolicy

@InterfaceAudience.Private
public class RatioBasedCompactionPolicy
extends CompactionPolicy

The default algorithm for selecting files for compaction. Combines the compaction configuration and the provisional file selection that it's given to produce the list of suitable candidates for compaction.


Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.compactions.CompactionPolicy
comConf, storeConfigInfo
 
Constructor Summary
RatioBasedCompactionPolicy(org.apache.hadoop.conf.Configuration conf, StoreConfigInformation storeConfigInfo)
           
 
Method Summary
protected  ArrayList<StoreFile> checkMinFilesCriteria(ArrayList<StoreFile> candidates)
           
protected  ArrayList<StoreFile> filterBulk(ArrayList<StoreFile> candidates)
           
 long getNextMajorCompactTime(Collection<StoreFile> filesToCompact)
           
 boolean isMajorCompaction(Collection<StoreFile> filesToCompact)
           
 boolean needsCompaction(Collection<StoreFile> storeFiles, List<StoreFile> filesCompacting)
           
 List<StoreFile> preSelectCompactionForCoprocessor(Collection<StoreFile> candidates, List<StoreFile> filesCompacting)
           
 CompactionRequest selectCompaction(Collection<StoreFile> candidateFiles, List<StoreFile> filesCompacting, boolean isUserCompaction, boolean mayUseOffPeak, boolean forceMajor)
           
 void setMinThreshold(int minThreshold)
          Overwrite min threshold for compaction
protected  ArrayList<StoreFile> skipLargeFiles(ArrayList<StoreFile> candidates)
           
 boolean throttleCompaction(long compactionSize)
           
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.compactions.CompactionPolicy
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RatioBasedCompactionPolicy

public RatioBasedCompactionPolicy(org.apache.hadoop.conf.Configuration conf,
                                  StoreConfigInformation storeConfigInfo)
Method Detail

preSelectCompactionForCoprocessor

public List<StoreFile> preSelectCompactionForCoprocessor(Collection<StoreFile> candidates,
                                                         List<StoreFile> filesCompacting)

selectCompaction

public CompactionRequest selectCompaction(Collection<StoreFile> candidateFiles,
                                          List<StoreFile> filesCompacting,
                                          boolean isUserCompaction,
                                          boolean mayUseOffPeak,
                                          boolean forceMajor)
                                   throws IOException
Parameters:
candidateFiles - candidate files, ordered from oldest to newest by seqId. We rely on DefaultStoreFileManager to sort the files by seqId to guarantee contiguous compaction based on seqId for data consistency.
Returns:
subset copy of candidate list that meets compaction criteria
Throws:
IOException

skipLargeFiles

protected ArrayList<StoreFile> skipLargeFiles(ArrayList<StoreFile> candidates)
Parameters:
candidates - pre-filtrate
Returns:
filtered subset exclude all files above maxCompactSize Also save all references. We MUST compact them

filterBulk

protected ArrayList<StoreFile> filterBulk(ArrayList<StoreFile> candidates)
Parameters:
candidates - pre-filtrate
Returns:
filtered subset exclude all bulk load files if configured

checkMinFilesCriteria

protected ArrayList<StoreFile> checkMinFilesCriteria(ArrayList<StoreFile> candidates)
Parameters:
candidates - pre-filtrate
Returns:
filtered subset forget the compactionSelection if we don't have enough files

isMajorCompaction

public boolean isMajorCompaction(Collection<StoreFile> filesToCompact)
                          throws IOException
Specified by:
isMajorCompaction in class CompactionPolicy
Parameters:
filesToCompact - Files to compact. Can be null.
Returns:
True if we should run a major compaction.
Throws:
IOException

getNextMajorCompactTime

public long getNextMajorCompactTime(Collection<StoreFile> filesToCompact)

throttleCompaction

public boolean throttleCompaction(long compactionSize)
Specified by:
throttleCompaction in class CompactionPolicy
Parameters:
compactionSize - Total size of some compaction
Returns:
whether this should be a large or small compaction

needsCompaction

public boolean needsCompaction(Collection<StoreFile> storeFiles,
                               List<StoreFile> filesCompacting)

setMinThreshold

public void setMinThreshold(int minThreshold)
Overwrite min threshold for compaction

Parameters:
minThreshold -


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