Map<FileRef,Pair<Key,Key>> firstAndLastKeys = null;
if (reason == MajorCompactionReason.CHOP) {
firstAndLastKeys = getFirstAndLastKeys(datafileManager.getDatafileSizes());
} else if (reason != MajorCompactionReason.USER) {
MajorCompactionRequest request = new MajorCompactionRequest(extent, reason, fs, acuTableConf);
request.setFiles(datafileManager.getDatafileSizes());
strategy.gatherInformation(request);
}
Map<FileRef,DataFileValue> filesToCompact;
int maxFilesToCompact = acuTableConf.getCount(Property.TSERV_MAJC_THREAD_MAXOPEN);
CompactionStats majCStats = new CompactionStats();
CompactionPlan plan = null;
boolean propogateDeletes = false;
synchronized (this) {
// plan all that work that needs to be done in the sync block... then do the actual work
// outside the sync block
t1 = System.currentTimeMillis();
majorCompactionWaitingToStart = true;
tabletMemory.waitForMinC();
t2 = System.currentTimeMillis();
majorCompactionWaitingToStart = false;
notifyAll();
if (extent.isRootTablet()) {
// very important that we call this before doing major compaction,
// otherwise deleted compacted files could possible be brought back
// at some point if the file they were compacted to was legitimately
// removed by a major compaction
RootFiles.cleanupReplacement(fs, fs.listStatus(this.location), false);
}
SortedMap<FileRef,DataFileValue> allFiles = datafileManager.getDatafileSizes();
List<FileRef> inputFiles = new ArrayList<FileRef>();
if (reason == MajorCompactionReason.CHOP) {
// enforce rules: files with keys outside our range need to be compacted
inputFiles.addAll(findChopFiles(extent, firstAndLastKeys, allFiles.keySet()));
} else if (reason == MajorCompactionReason.USER) {
inputFiles.addAll(allFiles.keySet());
} else {
MajorCompactionRequest request = new MajorCompactionRequest(extent, reason, fs, acuTableConf);
request.setFiles(allFiles);
plan = strategy.getCompactionPlan(request);
if (plan != null)
inputFiles.addAll(plan.inputFiles);
}