Last active
September 14, 2016 11:58
-
-
Save mwkang/d32d739f4aed0703bd7c688236f34d96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private boolean isBetterSelection(List<StoreFile> bestSelection, | |
| long bestSize, List<StoreFile> selection, long size, boolean mightBeStuck) { | |
| if (mightBeStuck && bestSize > 0 && size > 0) { | |
| // Keep the selection that removes most files for least size. That penaltizes adding | |
| // large files to compaction, but not small files, so we don't become totally inefficient | |
| // (might want to tweak that in future). Also, given the current order of looking at | |
| // permutations, prefer earlier files and smaller selection if the difference is small. | |
| final double REPLACE_IF_BETTER_BY = 1.05; | |
| double thresholdQuality = ((double)bestSelection.size() / bestSize) * REPLACE_IF_BETTER_BY; | |
| return thresholdQuality < ((double)selection.size() / size); | |
| } | |
| // Keep if this gets rid of more files. Or the same number of files for less io. | |
| return selection.size() > bestSelection.size() | |
| || (selection.size() == bestSelection.size() && size < bestSize); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment