@InterfaceAudience.Private
public class AdaptiveMemStoreCompactionStrategy
extends MemStoreCompactionStrategy
Adaptive is a heuristic that chooses whether to apply data compaction or not based on the level
of redundancy in the data. Adaptive triggers redundancy elimination only for those stores where
positive impact is expected. Adaptive uses two parameters to determine whether to perform
redundancy elimination. The first parameter, u, estimates the ratio of unique keys in the memory
store based on the fraction of unique keys encountered during the previous merge of segment
indices. The second is the perceived probability (compactionProbability) that the store can
benefit from redundancy elimination. Initially, compactionProbability=0.5; it then grows
exponentially by 2% whenever a compaction is successful and decreased by 2% whenever a compaction
did not meet the expectation. It is reset back to the default value (namely 0.5) upon disk flush.
Adaptive triggers redundancy elimination with probability compactionProbability if the fraction
of redundant keys 1-u exceeds a parameter threshold compactionThreshold.