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.SortedCompactionPolicy
          extended by org.apache.hadoop.hbase.regionserver.compactions.RatioBasedCompactionPolicy
Direct Known Subclasses:
ExploringCompactionPolicy

@InterfaceAudience.Private
public class RatioBasedCompactionPolicy
extends SortedCompactionPolicy

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> applyCompactionPolicy(ArrayList<StoreFile> candidates, boolean mayUseOffPeak, boolean mayBeStuck)
           
protected  CompactionRequest getCompactionRequest(ArrayList<StoreFile> candidateSelection, boolean tryingMajor, boolean isUserCompaction, boolean mayUseOffPeak, boolean mayBeStuck)
           
 void setMinThreshold(int minThreshold)
          Overwrite min threshold for compaction
 boolean shouldPerformMajorCompaction(Collection<StoreFile> filesToCompact)
           
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.compactions.SortedCompactionPolicy
checkMinFilesCriteria, filterBulk, getCurrentEligibleFiles, getNextMajorCompactTime, needsCompaction, preSelectCompactionForCoprocessor, removeExcessFiles, selectCompaction, skipLargeFiles, throttleCompaction
 
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

shouldPerformMajorCompaction

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

getCompactionRequest

protected CompactionRequest getCompactionRequest(ArrayList<StoreFile> candidateSelection,
                                                 boolean tryingMajor,
                                                 boolean isUserCompaction,
                                                 boolean mayUseOffPeak,
                                                 boolean mayBeStuck)
                                          throws IOException
Specified by:
getCompactionRequest in class SortedCompactionPolicy
Throws:
IOException

applyCompactionPolicy

protected ArrayList<StoreFile> applyCompactionPolicy(ArrayList<StoreFile> candidates,
                                                     boolean mayUseOffPeak,
                                                     boolean mayBeStuck)
                                              throws IOException
Parameters:
candidates - pre-filtrate
Returns:
filtered subset -- Default minor compaction selection algorithm: choose CompactSelection from candidates -- First exclude bulk-load files if indicated in configuration. Start at the oldest file and stop when you find the first file that meets compaction criteria: (1) a recently-flushed, small file (i.e. <= minCompactSize) OR (2) within the compactRatio of sum(newer_files) Given normal skew, any newer files will also meet this criteria

Additional Note: If fileSizes.size() >> maxFilesToCompact, we will recurse on compact(). Consider the oldest files first to avoid a situation where we always compact [end-threshold,end). Then, the last file becomes an aggregate of the previous compactions. normal skew: older ----> newer (increasing seqID) _ | | _ | | | | _ --|-|- |-|- |-|---_-------_------- minCompactSize | | | | | | | | _ | | | | | | | | | | | | | | | | | | | | | | | | | |

Throws:
IOException

setMinThreshold

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

Parameters:
minThreshold -


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