Class MergePolicy

java.lang.Object
org.apache.lucene.index.MergePolicy
Direct Known Subclasses:
FilterMergePolicy, LogMergePolicy, NoMergePolicy, TieredMergePolicy

public abstract class MergePolicy extends Object
Expert: a MergePolicy determines the sequence of primitive merge operations.

Whenever the segments in an index have been altered by IndexWriter, either the addition of a newly flushed segment, addition of many segments from addIndexes* calls, or a previous merge that may now need to cascade, IndexWriter invokes findMerges(org.apache.lucene.index.MergeTrigger, org.apache.lucene.index.SegmentInfos, org.apache.lucene.index.MergePolicy.MergeContext) to give the MergePolicy a chance to pick merges that are now required. This method returns a MergePolicy.MergeSpecification instance describing the set of merges that should be done, or null if no merges are necessary. When IndexWriter.forceMerge is called, it calls findForcedMerges(SegmentInfos, int, Map, MergeContext) and the MergePolicy should then return the necessary merges.

Note that the policy can return more than one merge at a time. In this case, if the writer is using SerialMergeScheduler, the merges will be run sequentially but if it is using ConcurrentMergeScheduler they will be run concurrently.

The default MergePolicy is TieredMergePolicy.

WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • DEFAULT_NO_CFS_RATIO

      protected static final double DEFAULT_NO_CFS_RATIO
      Default ratio for compound file system usage. Set to 1.0, always use compound file system.
      See Also:
    • DEFAULT_MAX_CFS_SEGMENT_SIZE

      protected static final long DEFAULT_MAX_CFS_SEGMENT_SIZE
      Default max segment size in order to use compound file system. Set to Long.MAX_VALUE.
      See Also:
    • noCFSRatio

      protected double noCFSRatio
      If the size of the merge segment exceeds this ratio of the total index size then it will remain in non-compound format
    • maxCFSSegmentSize

      protected long maxCFSSegmentSize
      If the size of the merged segment exceeds this value then it will not use compound file format.
  • Constructor Details

    • MergePolicy

      protected MergePolicy()
      Creates a new merge policy instance.
    • MergePolicy

      protected MergePolicy(double defaultNoCFSRatio, long defaultMaxCFSSegmentSize)
      Creates a new merge policy instance with default settings for noCFSRatio and maxCFSSegmentSize. This ctor should be used by subclasses using different defaults than the MergePolicy
  • Method Details