CompactionPolicy selectCompactionPolicyAndUpdateCompactionPolicySwitchInfo(
      CompactionPolicySwitchInfo compactionPolicySwitchInfo, String storeId, String dataDir) {
    if (compactionPolicySwitchInfo == null) {
      logger.trace("CompactionPolicySwitchInfo is null for store : {}, dataDir : {}", storeId, dataDir);
      return statsBasedPolicy;
    }
    if (readyToTriggerCompactionAllPolicy(compactionPolicySwitchInfo)) {
      logger.trace("Return CompactAllPolicy this round for store : {}, dataDir : {}", storeId, dataDir);
      updateCompactionInfoWhenCompactAll(compactionPolicySwitchInfo);
      return compactAllPolicy;
    } else {
      if (compactionPolicySwitchInfo.getLastCompactAllTime() == 0) {
        logger.error("Last compact all time is {} for store : {}, dataDir : {}",
            compactionPolicySwitchInfo.getLastCompactAllTime(), storeId, dataDir);
      } else {
        logger.trace("Return StatsBasedCompactionPolicy this round for store : {}, dataDir : {}", storeId, dataDir);
      }
      if (compactionPolicySwitchInfo.getLastCompactAllTime() + TimeUnit.DAYS.toMillis(
          storeConfig.storeCompactionPolicySwitchTimestampDays) + staggerDelay() <= System.currentTimeMillis()) {
        logger.trace("Set next round is compactAllPolicy to true");
        compactionPolicySwitchInfo.setNextRoundIsCompactAllPolicy(true);
      }
      return statsBasedPolicy;
    }
  }
Selects which compaction policy to use for current compaction cycle.
@param compactionPolicySwitchInfo the info to determine which {@link CompactionPolicy} to use this round.
@param storeId id of the BlobStore
@param dataDir The directory to store the file.
@return {@link CompactionPolicy} to use for current compaction cycle(Selects between {@link StatsBasedCompactionPolicy} and {@link CompactAllPolicy}).
ambry-store/src/main/java/com/github/ambry/store/HybridCompactionPolicy.java