test_class.file: oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/CommitMitigatingTieredMergePolicyTest.java
test_class.identifier: CommitMitigatingTieredMergePolicyTest
test_case.body: @Test
      public void testMergeWithNoSegments() throws Exception {
          CommitMitigatingTieredMergePolicy mergePolicy = new CommitMitigatingTieredMergePolicy();
  
          SegmentInfos infos = new SegmentInfos();
          MergePolicy.MergeSpecification merges = mergePolicy.findMerges(MergeTrigger.SEGMENT_FLUSH, infos);
          assertNull(merges);
      }
test_case.class_method_signature: CommitMitigatingTieredMergePolicyTest.testMergeWithNoSegments()
test_case.full_signature: @Test public void testMergeWithNoSegments()
test_case.identifier: testMergeWithNoSegments
test_case.invocations: findMerges assertNull
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMergeWithNoSegments()
focal_class.declarator: log = LoggerFactory.getLogger(getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(getClass());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: DEFAULT_NO_CFS_RATIO = 0.1
focal_class.modifier: public static final
focal_class.original_string: public static final double DEFAULT_NO_CFS_RATIO = 0.1;
focal_class.type: double
focal_class.var_name: DEFAULT_NO_CFS_RATIO
focal_class.declarator: DEFAULT_MAX_COMMIT_RATE_DOCS = 1000
focal_class.modifier: private static final
focal_class.original_string: private static final double DEFAULT_MAX_COMMIT_RATE_DOCS = 1000;
focal_class.type: double
focal_class.var_name: DEFAULT_MAX_COMMIT_RATE_DOCS
focal_class.declarator: DEFAULT_MAX_COMMIT_RATE_MB = 5
focal_class.modifier: private static final
focal_class.original_string: private static final double DEFAULT_MAX_COMMIT_RATE_MB = 5;
focal_class.type: double
focal_class.var_name: DEFAULT_MAX_COMMIT_RATE_MB
focal_class.declarator: DEFAULT_MAX_NO_OF_SEGS_FOR_MITIGATION = 20
focal_class.modifier: private static final
focal_class.original_string: private static final int DEFAULT_MAX_NO_OF_SEGS_FOR_MITIGATION = 20;
focal_class.type: int
focal_class.var_name: DEFAULT_MAX_NO_OF_SEGS_FOR_MITIGATION
focal_class.declarator: maxMergeAtOnce = 10
focal_class.modifier: private
focal_class.original_string: private int maxMergeAtOnce = 10;
focal_class.type: int
focal_class.var_name: maxMergeAtOnce
focal_class.declarator: maxMergedSegmentBytes = 5 * 1024 * 1024 * 1024L
focal_class.modifier: private
focal_class.original_string: private long maxMergedSegmentBytes = 5 * 1024 * 1024 * 1024L;
focal_class.type: long
focal_class.var_name: maxMergedSegmentBytes
focal_class.declarator: maxMergeAtOnceExplicit = 30
focal_class.modifier: private
focal_class.original_string: private int maxMergeAtOnceExplicit = 30;
focal_class.type: int
focal_class.var_name: maxMergeAtOnceExplicit
focal_class.declarator: floorSegmentBytes = 2 * 1024 * 1024L
focal_class.modifier: private
focal_class.original_string: private long floorSegmentBytes = 2 * 1024 * 1024L;
focal_class.type: long
focal_class.var_name: floorSegmentBytes
focal_class.declarator: segsPerTier = 10.0
focal_class.modifier: private
focal_class.original_string: private double segsPerTier = 10.0;
focal_class.type: double
focal_class.var_name: segsPerTier
focal_class.declarator: forceMergeDeletesPctAllowed = 10.0
focal_class.modifier: private
focal_class.original_string: private double forceMergeDeletesPctAllowed = 10.0;
focal_class.type: double
focal_class.var_name: forceMergeDeletesPctAllowed
focal_class.declarator: reclaimDeletesWeight = 1.5
focal_class.modifier: private
focal_class.original_string: private double reclaimDeletesWeight = 1.5;
focal_class.type: double
focal_class.var_name: reclaimDeletesWeight
focal_class.declarator: maxCommitRateDocs = DEFAULT_MAX_COMMIT_RATE_DOCS
focal_class.modifier: private
focal_class.original_string: private double maxCommitRateDocs = DEFAULT_MAX_COMMIT_RATE_DOCS;
focal_class.type: double
focal_class.var_name: maxCommitRateDocs
focal_class.declarator: maxCommitRateMB = DEFAULT_MAX_COMMIT_RATE_MB
focal_class.modifier: private
focal_class.original_string: private double maxCommitRateMB = DEFAULT_MAX_COMMIT_RATE_MB;
focal_class.type: double
focal_class.var_name: maxCommitRateMB
focal_class.declarator: maxNoOfSegsForMitigation = DEFAULT_MAX_NO_OF_SEGS_FOR_MITIGATION
focal_class.modifier: private
focal_class.original_string: private int maxNoOfSegsForMitigation = DEFAULT_MAX_NO_OF_SEGS_FOR_MITIGATION;
focal_class.type: int
focal_class.var_name: maxNoOfSegsForMitigation
focal_class.declarator: docCount = 0d
focal_class.modifier: private
focal_class.original_string: private double docCount = 0d;
focal_class.type: double
focal_class.var_name: docCount
focal_class.declarator: mb = 0d
focal_class.modifier: private
focal_class.original_string: private double mb = 0d;
focal_class.type: double
focal_class.var_name: mb
focal_class.declarator: time = System.currentTimeMillis()
focal_class.modifier: private
focal_class.original_string: private double time = System.currentTimeMillis();
focal_class.type: double
focal_class.var_name: time
focal_class.declarator: avgCommitRateDocs = 0d
focal_class.modifier: private
focal_class.original_string: private double avgCommitRateDocs = 0d;
focal_class.type: double
focal_class.var_name: avgCommitRateDocs
focal_class.declarator: avgCommitRateMB = 0d
focal_class.modifier: private
focal_class.original_string: private double avgCommitRateMB = 0d;
focal_class.type: double
focal_class.var_name: avgCommitRateMB
focal_class.declarator: avgSegs = 0
focal_class.modifier: private
focal_class.original_string: private double avgSegs = 0;
focal_class.type: double
focal_class.var_name: avgSegs
focal_class.declarator: timeSeriesLength = 50d
focal_class.modifier: private
focal_class.original_string: private double timeSeriesLength = 50d;
focal_class.type: double
focal_class.var_name: timeSeriesLength
focal_class.declarator: timeSeriesCount = 0d
focal_class.modifier: private
focal_class.original_string: private double timeSeriesCount = 0d;
focal_class.type: double
focal_class.var_name: timeSeriesCount
focal_class.declarator: alpha = 0.7
focal_class.modifier: private
focal_class.original_string: private double alpha = 0.7;
focal_class.type: double
focal_class.var_name: alpha
focal_class.file: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/CommitMitigatingTieredMergePolicy.java
focal_class.identifier: CommitMitigatingTieredMergePolicy
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.CommitMitigatingTieredMergePolicy()
focal_class.full_signature: public  CommitMitigatingTieredMergePolicy()
focal_class.identifier: CommitMitigatingTieredMergePolicy
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CommitMitigatingTieredMergePolicy()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxMergeAtOnce(int v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxMergeAtOnce(int v)
focal_class.identifier: setMaxMergeAtOnce
focal_class.modifiers: public
focal_class.parameters: (int v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxMergeAtOnce(int v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxNoOfSegsForMitigation(int maxNoOfSegsForMitigation)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxNoOfSegsForMitigation(int maxNoOfSegsForMitigation)
focal_class.identifier: setMaxNoOfSegsForMitigation
focal_class.modifiers: public
focal_class.parameters: (int maxNoOfSegsForMitigation)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxNoOfSegsForMitigation(int maxNoOfSegsForMitigation)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxCommitRateDocs(double maxCommitRate)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxCommitRateDocs(double maxCommitRate)
focal_class.identifier: setMaxCommitRateDocs
focal_class.modifiers: public
focal_class.parameters: (double maxCommitRate)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxCommitRateDocs(double maxCommitRate)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getMaxMergeAtOnce()
focal_class.full_signature: public int getMaxMergeAtOnce()
focal_class.identifier: getMaxMergeAtOnce
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMaxMergeAtOnce()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxMergeAtOnceExplicit(int v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxMergeAtOnceExplicit(int v)
focal_class.identifier: setMaxMergeAtOnceExplicit
focal_class.modifiers: public
focal_class.parameters: (int v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxMergeAtOnceExplicit(int v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getMaxMergeAtOnceExplicit()
focal_class.full_signature: public int getMaxMergeAtOnceExplicit()
focal_class.identifier: getMaxMergeAtOnceExplicit
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMaxMergeAtOnceExplicit()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxMergedSegmentMB(double v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxMergedSegmentMB(double v)
focal_class.identifier: setMaxMergedSegmentMB
focal_class.modifiers: public
focal_class.parameters: (double v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxMergedSegmentMB(double v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getMaxMergedSegmentMB()
focal_class.full_signature: public double getMaxMergedSegmentMB()
focal_class.identifier: getMaxMergedSegmentMB
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getMaxMergedSegmentMB()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setReclaimDeletesWeight(double v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setReclaimDeletesWeight(double v)
focal_class.identifier: setReclaimDeletesWeight
focal_class.modifiers: public
focal_class.parameters: (double v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setReclaimDeletesWeight(double v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getReclaimDeletesWeight()
focal_class.full_signature: public double getReclaimDeletesWeight()
focal_class.identifier: getReclaimDeletesWeight
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getReclaimDeletesWeight()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setFloorSegmentMB(double v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setFloorSegmentMB(double v)
focal_class.identifier: setFloorSegmentMB
focal_class.modifiers: public
focal_class.parameters: (double v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setFloorSegmentMB(double v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getFloorSegmentMB()
focal_class.full_signature: public double getFloorSegmentMB()
focal_class.identifier: getFloorSegmentMB
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getFloorSegmentMB()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setForceMergeDeletesPctAllowed(double v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setForceMergeDeletesPctAllowed(double v)
focal_class.identifier: setForceMergeDeletesPctAllowed
focal_class.modifiers: public
focal_class.parameters: (double v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setForceMergeDeletesPctAllowed(double v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getForceMergeDeletesPctAllowed()
focal_class.full_signature: public double getForceMergeDeletesPctAllowed()
focal_class.identifier: getForceMergeDeletesPctAllowed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getForceMergeDeletesPctAllowed()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setSegmentsPerTier(double v)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setSegmentsPerTier(double v)
focal_class.identifier: setSegmentsPerTier
focal_class.modifiers: public
focal_class.parameters: (double v)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setSegmentsPerTier(double v)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.getSegmentsPerTier()
focal_class.full_signature: public double getSegmentsPerTier()
focal_class.identifier: getSegmentsPerTier
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: double
focal_class.signature: double getSegmentsPerTier()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.setMaxCommitRateMB(int maxCommitRateMB)
focal_class.full_signature: public CommitMitigatingTieredMergePolicy setMaxCommitRateMB(int maxCommitRateMB)
focal_class.identifier: setMaxCommitRateMB
focal_class.modifiers: public
focal_class.parameters: (int maxCommitRateMB)
focal_class.return: CommitMitigatingTieredMergePolicy
focal_class.signature: CommitMitigatingTieredMergePolicy setMaxCommitRateMB(int maxCommitRateMB)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
focal_class.full_signature: @Override public MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
focal_class.identifier: findMerges
focal_class.modifiers: @Override public
focal_class.parameters: (MergeTrigger mergeTrigger, SegmentInfos infos)
focal_class.return: MergeSpecification
focal_class.signature: MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.singleExpSmoothing(double input, double smoothedValue)
focal_class.full_signature: private double singleExpSmoothing(double input, double smoothedValue)
focal_class.identifier: singleExpSmoothing
focal_class.modifiers: private
focal_class.parameters: (double input, double smoothedValue)
focal_class.return: double
focal_class.signature: double singleExpSmoothing(double input, double smoothedValue)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.score(List<SegmentCommitInfo> candidate, boolean hitTooLarge, long mergingBytes)
focal_class.full_signature: protected MergeScore score(List<SegmentCommitInfo> candidate, boolean hitTooLarge, long mergingBytes)
focal_class.identifier: score
focal_class.modifiers: protected
focal_class.parameters: (List<SegmentCommitInfo> candidate, boolean hitTooLarge, long mergingBytes)
focal_class.return: MergeScore
focal_class.signature: MergeScore score(List<SegmentCommitInfo> candidate, boolean hitTooLarge, long mergingBytes)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map<SegmentCommitInfo, Boolean> segmentsToMerge)
focal_class.full_signature: @Override public MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map<SegmentCommitInfo, Boolean> segmentsToMerge)
focal_class.identifier: findForcedMerges
focal_class.modifiers: @Override public
focal_class.parameters: (SegmentInfos infos, int maxSegmentCount, Map<SegmentCommitInfo, Boolean> segmentsToMerge)
focal_class.return: MergeSpecification
focal_class.signature: MergeSpecification findForcedMerges(SegmentInfos infos, int maxSegmentCount, Map<SegmentCommitInfo, Boolean> segmentsToMerge)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.findForcedDeletesMerges(SegmentInfos infos)
focal_class.full_signature: @Override public MergeSpecification findForcedDeletesMerges(SegmentInfos infos)
focal_class.identifier: findForcedDeletesMerges
focal_class.modifiers: @Override public
focal_class.parameters: (SegmentInfos infos)
focal_class.return: MergeSpecification
focal_class.signature: MergeSpecification findForcedDeletesMerges(SegmentInfos infos)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.close()
focal_class.full_signature: @Override public void close()
focal_class.identifier: close
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.floorSize(long bytes)
focal_class.full_signature: private long floorSize(long bytes)
focal_class.identifier: floorSize
focal_class.modifiers: private
focal_class.parameters: (long bytes)
focal_class.return: long
focal_class.signature: long floorSize(long bytes)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.verbose()
focal_class.full_signature: private boolean verbose()
focal_class.identifier: verbose
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean verbose()
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.message(String message)
focal_class.full_signature: private void message(String message)
focal_class.identifier: message
focal_class.modifiers: private
focal_class.parameters: (String message)
focal_class.return: void
focal_class.signature: void message(String message)
focal_class.class_method_signature: CommitMitigatingTieredMergePolicy.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.superclass: extends MergePolicy
focal_method.body: @Override
      public MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos infos) throws IOException {
          int segmentSize = infos.size();
          timeSeriesCount++;
  
          if (timeSeriesCount % timeSeriesLength == 0) {
              // reset averages
              avgCommitRateDocs = 0d;
              avgCommitRateMB = 0d;
              avgSegs = 0d;
          }
          avgSegs = singleExpSmoothing(segmentSize, avgSegs);
  
          log.debug("segments: current {}, average {}", segmentSize, avgSegs);
  
          if (verbose()) {
              message("findMerges: " + segmentSize + " segments, " + avgSegs + " average");
          }
          if (segmentSize == 0) {
              return null;
          }
  
          // if no. of segments exceeds the maximum, adjust the maximum rates to allow more merges (less commit/rate mitigation)
          if (segmentSize > maxNoOfSegsForMitigation) {
              if (avgCommitRateDocs > maxCommitRateDocs) {
                  double v = singleExpSmoothing(avgCommitRateDocs, maxCommitRateDocs);
                  log.debug("adjusting maxCommitRateDocs from {} to {}", maxCommitRateDocs, v);
                  maxCommitRateDocs = v;
              }
              if (avgCommitRateMB > maxCommitRateMB) {
                  double v = singleExpSmoothing(avgCommitRateMB, maxCommitRateMB);
                  log.debug("adjusting maxCommitRateMB from {} to {}", maxCommitRateMB, v);
                  maxCommitRateMB = v;
              }
          }
  
          long now = System.currentTimeMillis();
          double timeDelta = (now / 1000d) - (time / 1000d);
          double commitRate = Math.abs(docCount - infos.totalDocCount()) / timeDelta;
          time = now;
  
          avgCommitRateDocs = singleExpSmoothing(commitRate, avgCommitRateDocs);
  
          log.debug("commit rate: current {}, average {}, max {} docs/sec", commitRate, avgCommitRateDocs, maxCommitRateDocs);
  
          docCount = infos.totalDocCount();
  
          if (verbose()) {
              message(commitRate + "doc/s (max: " + maxCommitRateDocs + ", avg: " + avgCommitRateDocs + " doc/s)");
          }
  
          // do not mitigate if there're too many segments to avoid affecting performance
          if (commitRate > maxCommitRateDocs && segmentSize < maxNoOfSegsForMitigation) {
              log.debug("mitigation due to {} > {} docs/sec and segments {} < {})", commitRate, maxCommitRateDocs,
                      segmentSize, maxNoOfSegsForMitigation);
              return null;
          }
  
          final Collection<SegmentCommitInfo> merging = writer.get().getMergingSegments();
          final Collection<SegmentCommitInfo> toBeMerged = new HashSet<SegmentCommitInfo>();
  
          final List<SegmentCommitInfo> infosSorted = new ArrayList<SegmentCommitInfo>(infos.asList());
          Collections.sort(infosSorted, new SegmentByteSizeDescending());
  
          // Compute total index bytes & print details about the index
          long totIndexBytes = 0;
          long minSegmentBytes = Long.MAX_VALUE;
          for (SegmentCommitInfo info : infosSorted) {
              final long segBytes = size(info);
              if (verbose()) {
                  String extra = merging.contains(info) ? " [merging]" : "";
                  if (segBytes >= maxMergedSegmentBytes / 2.0) {
                      extra += " [skip: too large]";
                  } else if (segBytes < floorSegmentBytes) {
                      extra += " [floored]";
                  }
                  message("  seg=" + writer.get().segString(info) + " size=" + String.format(Locale.ROOT, "%.3f", segBytes / 1024 / 1024.) + " MB" + extra);
              }
  
              minSegmentBytes = Math.min(segBytes, minSegmentBytes);
              // Accum total byte size
              totIndexBytes += segBytes;
          }
  
          // If we have too-large segments, grace them out
          // of the maxSegmentCount:
          int tooBigCount = 0;
          while (tooBigCount < infosSorted.size() && size(infosSorted.get(tooBigCount)) >= maxMergedSegmentBytes / 2.0) {
              totIndexBytes -= size(infosSorted.get(tooBigCount));
              tooBigCount++;
          }
  
          minSegmentBytes = floorSize(minSegmentBytes);
  
          // Compute max allowed segs in the index
          long levelSize = minSegmentBytes;
          long bytesLeft = totIndexBytes;
          double allowedSegCount = 0;
          while (true) {
              final double segCountLevel = bytesLeft / (double) levelSize;
              if (segCountLevel < segsPerTier) {
                  allowedSegCount += Math.ceil(segCountLevel);
                  break;
              }
              allowedSegCount += segsPerTier;
              bytesLeft -= segsPerTier * levelSize;
              levelSize *= maxMergeAtOnce;
          }
          int allowedSegCountInt = (int) allowedSegCount;
  
          MergeSpecification spec = null;
  
          // Cycle to possibly select more than one merge:
          while (true) {
  
              long mergingBytes = 0;
              double idxBytes = 0;
  
              // Gather eligible segments for merging, ie segments
              // not already being merged and not already picked (by
              // prior iteration of this loop) for merging:
              final List<SegmentCommitInfo> eligible = new ArrayList<SegmentCommitInfo>();
              for (int idx = tooBigCount; idx < infosSorted.size(); idx++) {
                  final SegmentCommitInfo info = infosSorted.get(idx);
                  if (merging.contains(info)) {
                      mergingBytes += info.sizeInBytes();
                  } else if (!toBeMerged.contains(info)) {
                      eligible.add(info);
                  }
                  idxBytes += info.sizeInBytes();
              }
              idxBytes /= 1024d * 1024d;
  
              final boolean maxMergeIsRunning = mergingBytes >= maxMergedSegmentBytes;
  
              if (verbose()) {
                  message("  allowedSegmentCount=" + allowedSegCountInt + " vs count=" + infosSorted.size() + " (eligible count=" + eligible.size() + ") tooBigCount=" + tooBigCount);
              }
  
              if (eligible.size() == 0) {
                  return spec;
              }
  
              double bytes = idxBytes - this.mb;
              double mbRate = bytes / timeDelta;
  
              avgCommitRateMB = singleExpSmoothing(mbRate, avgCommitRateMB);
  
              log.debug("commit rate: current {}, average {}, max {} MB/sec", mbRate, avgCommitRateMB, maxCommitRateMB);
  
              if (verbose()) {
                  message(mbRate + "mb/s (max: " + maxCommitRateMB + ", avg: " + avgCommitRateMB + " MB/s)");
              }
  
              this.mb = idxBytes;
  
              // do not mitigate if there're too many segments to avoid affecting performance
              if (mbRate > maxCommitRateMB && segmentSize < maxNoOfSegsForMitigation) {
                  log.debug("mitigation due to {} > {} MB/sec and segments {} < {})", mbRate, maxCommitRateMB,
                          segmentSize, maxNoOfSegsForMitigation);
                  return null;
              }
  
              if (eligible.size() >= allowedSegCountInt) {
  
                  // OK we are over budget -- find best merge!
                  MergeScore bestScore = null;
                  List<SegmentCommitInfo> best = null;
                  boolean bestTooLarge = false;
                  long bestMergeBytes = 0;
  
                  // Consider all merge starts:
                  for (int startIdx = 0; startIdx <= eligible.size() - maxMergeAtOnce; startIdx++) {
  
                      long totAfterMergeBytes = 0;
  
                      final List<SegmentCommitInfo> candidate = new ArrayList<SegmentCommitInfo>();
                      boolean hitTooLarge = false;
                      for (int idx = startIdx; idx < eligible.size() && candidate.size() < maxMergeAtOnce; idx++) {
                          final SegmentCommitInfo info = eligible.get(idx);
                          final long segBytes = size(info);
  
                          if (totAfterMergeBytes + segBytes > maxMergedSegmentBytes) {
                              hitTooLarge = true;
                              // NOTE: we continue, so that we can try
                              // "packing" smaller segments into this merge
                              // to see if we can get closer to the max
                              // size; this in general is not perfect since
                              // this is really "bin packing" and we'd have
                              // to try different permutations.
                              continue;
                          }
                          candidate.add(info);
                          totAfterMergeBytes += segBytes;
                      }
  
                      final MergeScore score = score(candidate, hitTooLarge, mergingBytes);
                      if (verbose()) {
                          message("  maybe=" + writer.get().segString(candidate) + " score=" + score.getScore() + " " + score.getExplanation() + " tooLarge=" + hitTooLarge + " size=" + String.format(Locale.ROOT, "%.3f MB", totAfterMergeBytes / 1024. / 1024.));
                      }
  
                      // If we are already running a max sized merge
                      // (maxMergeIsRunning), don't allow another max
                      // sized merge to kick off:
                      if ((bestScore == null || score.getScore() < bestScore.getScore()) && (!hitTooLarge || !maxMergeIsRunning)) {
                          best = candidate;
                          bestScore = score;
                          bestTooLarge = hitTooLarge;
                          bestMergeBytes = totAfterMergeBytes;
                      }
                  }
  
                  if (best != null) {
                      if (spec == null) {
                          spec = new MergeSpecification();
                      }
                      final OneMerge merge = new OneMerge(best);
                      spec.add(merge);
                      for (SegmentCommitInfo info : merge.segments) {
                          toBeMerged.add(info);
                      }
                      if (verbose()) {
                          message("  add merge=" + writer.get().segString(merge.segments) + " size=" + String.format(Locale.ROOT, "%.3f MB", bestMergeBytes / 1024. / 1024.) + " score=" + String.format(Locale.ROOT, "%.3f", bestScore.getScore()) + " " + bestScore.getExplanation() + (bestTooLarge ? " [max merge]" : ""));
                      }
                  } else {
                      return spec;
                  }
              } else {
                  return spec;
              }
          }
      }
focal_method.class_method_signature: CommitMitigatingTieredMergePolicy.findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
focal_method.full_signature: @Override public MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
focal_method.identifier: findMerges
focal_method.invocations: size singleExpSmoothing debug verbose message singleExpSmoothing debug singleExpSmoothing debug currentTimeMillis abs totalDocCount singleExpSmoothing debug totalDocCount verbose message debug getMergingSegments get asList sort size verbose contains message segString get format min size size get size get floorSize ceil size get contains sizeInBytes contains add sizeInBytes verbose message size size size singleExpSmoothing debug verbose message debug size size size size get size add score verbose message segString get getScore getExplanation format getScore getScore add add verbose message segString get format format getScore getExplanation
focal_method.modifiers: @Override public
focal_method.parameters: (MergeTrigger mergeTrigger, SegmentInfos infos)
focal_method.return: MergeSpecification
focal_method.signature: MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos infos)