Class MostFragmentedIntervalFirstPolicy

java.lang.Object
org.apache.druid.server.compaction.BaseCandidateSearchPolicy
org.apache.druid.server.compaction.MostFragmentedIntervalFirstPolicy
All Implemented Interfaces:
CompactionCandidateSearchPolicy

public class MostFragmentedIntervalFirstPolicy extends BaseCandidateSearchPolicy
Experimental CompactionCandidateSearchPolicy which prioritizes compaction of intervals with the largest number of small uncompacted segments.

This policy favors cluster stability (by prioritizing reduction of segment count) over performance of queries on newer intervals. For the latter, use NewestSegmentFirstPolicy.

  • Constructor Details

    • MostFragmentedIntervalFirstPolicy

      public MostFragmentedIntervalFirstPolicy(@Nullable Integer minUncompactedCount, @Nullable HumanReadableBytes minUncompactedBytes, @Nullable HumanReadableBytes maxAverageUncompactedBytesPerSegment, @Nullable Integer minUncompactedBytesPercentForFullCompaction, @Nullable Integer minUncompactedRowsPercentForFullCompaction, @Nullable String priorityDatasource)
  • Method Details

    • getMinUncompactedCount

      public int getMinUncompactedCount()
      Minimum number of uncompacted segments that must be present in an interval to make it eligible for compaction.
    • getMinUncompactedBytes

      public HumanReadableBytes getMinUncompactedBytes()
      Minimum total bytes of uncompacted segments that must be present in an interval to make it eligible for compaction. Default value is SIZE_10_MB.
    • getMaxAverageUncompactedBytesPerSegment

      public HumanReadableBytes getMaxAverageUncompactedBytesPerSegment()
      Maximum average size of uncompacted segments in an interval eligible for compaction. Default value is SIZE_2_GB.
    • minUncompactedBytesPercentForFullCompaction

      public int minUncompactedBytesPercentForFullCompaction()
      Threshold percentage of uncompacted bytes to total bytes below which minor compaction is eligible instead of full compaction. Default value is 0.
    • minUncompactedRowsPercentForFullCompaction

      public int minUncompactedRowsPercentForFullCompaction()
      Threshold percentage of uncompacted rows to total rows below which minor compaction is eligible instead of full compaction. Default value is 0.
    • getSegmentComparator

      protected Comparator<CompactionCandidate> getSegmentComparator()
      Description copied from class: BaseCandidateSearchPolicy
      Compares between two compaction candidates. Used to determine the order in which segments and intervals should be picked for compaction.
      Specified by:
      getSegmentComparator in class BaseCandidateSearchPolicy
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BaseCandidateSearchPolicy
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseCandidateSearchPolicy
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • checkEligibilityForCompaction

      public Eligibility checkEligibilityForCompaction(CompactionCandidate candidate, CompactionTaskStatus latestTaskStatus)
      Description copied from interface: CompactionCandidateSearchPolicy
      Checks if the given CompactionCandidate is eligible for compaction in the current iteration. A policy may implement this method to skip compacting intervals or segments that do not fulfil some required criteria.
      Specified by:
      checkEligibilityForCompaction in interface CompactionCandidateSearchPolicy
      Overrides:
      checkEligibilityForCompaction in class BaseCandidateSearchPolicy
      Returns:
      Eligibility.FULL only if eligible.