Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class TieredMergePolicy

    Merges segments of approximately equal size, subject to an allowed number of segments per tier. This is similar to LogByteSizeMergePolicy, except this merge policy is able to merge non-adjacent segment, and separates how many segments are merged at once (MaxMergeAtOnce) from how many segments are allowed per tier (SegmentsPerTier). This merge policy also does not over-merge (i.e. cascade merges).

    For normal merging, this policy first computes a "budget" of how many segments are allowed to be in the index. If the index is over-budget, then the policy sorts segments by decreasing size (pro-rating by percent deletes), and then finds the least-cost merge. Merge cost is measured by a combination of the "skew" of the merge (size of largest segment divided by smallest segment), total merge size and percent deletes reclaimed, so that merges with lower skew, smaller size and those reclaiming more deletes, are favored.

    If a merge will produce a segment that's larger than MaxMergedSegmentMB, then the policy will merge fewer segments (down to 1 at once, if that one has deletions) to keep the segment size under budget.

    NOTE: This policy freely merges non-adjacent segments; if this is a problem, use LogMergePolicy.

    NOTE: This policy always merges by byte size of the segments, always pro-rates by percent deletes, and does not apply any maximum segment size during forceMerge (unlike LogByteSizeMergePolicy).

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    MergePolicy
    TieredMergePolicy
    Implements
    IDisposable
    Inherited Members
    MergePolicy.DEFAULT_MAX_CFS_SEGMENT_SIZE
    MergePolicy.m_writer
    MergePolicy.m_noCFSRatio
    MergePolicy.m_maxCFSSegmentSize
    MergePolicy.Clone()
    MergePolicy.SetIndexWriter(IndexWriter)
    MergePolicy.Dispose()
    MergePolicy.UseCompoundFile(SegmentInfos, SegmentCommitInfo)
    MergePolicy.Size(SegmentCommitInfo)
    MergePolicy.IsMerged(SegmentInfos, SegmentCommitInfo)
    MergePolicy.NoCFSRatio
    MergePolicy.MaxCFSSegmentSizeMB
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Index
    Assembly: Lucene.Net.dll
    Syntax
    public class TieredMergePolicy : MergePolicy, IDisposable

    Constructors

    TieredMergePolicy()

    Sole constructor, setting all settings to their defaults.

    Declaration
    public TieredMergePolicy()

    Fields

    DEFAULT_NO_CFS_RATIO

    Default noCFSRatio. If a merge's size is >= 10% of the index, then we disable compound file for it.

    Declaration
    public static readonly double DEFAULT_NO_CFS_RATIO
    Field Value
    Type Description
    double
    See Also
    NoCFSRatio

    Properties

    FloorSegmentMB

    Segments smaller than this are "rounded up" to this size, ie treated as equal (floor) size for merge selection. this is to prevent frequent flushing of tiny segments from allowing a long tail in the index. Default is 2 MB.

    Declaration
    public virtual double FloorSegmentMB { get; set; }
    Property Value
    Type Description
    double

    ForceMergeDeletesPctAllowed

    When forceMergeDeletes is called, we only merge away a segment if its delete percentage is over this threshold. Default is 10%.

    Declaration
    public virtual double ForceMergeDeletesPctAllowed { get; set; }
    Property Value
    Type Description
    double

    MaxMergeAtOnce

    Gets or sets maximum number of segments to be merged at a time during "normal" merging. For explicit merging (eg, ForceMerge(int) or ForceMergeDeletes() was called), see MaxMergeAtOnceExplicit. Default is 10.

    Declaration
    public virtual int MaxMergeAtOnce { get; set; }
    Property Value
    Type Description
    int

    MaxMergeAtOnceExplicit

    Gets or sets maximum number of segments to be merged at a time, during ForceMerge(int) or ForceMergeDeletes(). Default is 30.

    Declaration
    public virtual int MaxMergeAtOnceExplicit { get; set; }
    Property Value
    Type Description
    int

    MaxMergedSegmentMB

    Gets or sets maximum sized segment to produce during normal merging. This setting is approximate: the estimate of the merged segment size is made by summing sizes of to-be-merged segments (compensating for percent deleted docs). Default is 5 GB.

    Declaration
    public virtual double MaxMergedSegmentMB { get; set; }
    Property Value
    Type Description
    double

    ReclaimDeletesWeight

    Controls how aggressively merges that reclaim more deletions are favored. Higher values will more aggressively target merges that reclaim deletions, but be careful not to go so high that way too much merging takes place; a value of 3.0 is probably nearly too high. A value of 0.0 means deletions don't impact merge selection.

    Declaration
    public virtual double ReclaimDeletesWeight { get; set; }
    Property Value
    Type Description
    double

    SegmentsPerTier

    Gets or sets the allowed number of segments per tier. Smaller values mean more merging but fewer segments.

    NOTE: this value should be >= the MaxMergeAtOnce otherwise you'll force too much merging to occur.

    Default is 10.0.
    Declaration
    public virtual double SegmentsPerTier { get; set; }
    Property Value
    Type Description
    double

    Methods

    Dispose(bool)

    Release all resources for the policy.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    Overrides
    MergePolicy.Dispose(bool)

    FindForcedDeletesMerges(SegmentInfos)

    Determine what set of merge operations is necessary in order to expunge all deletes from the index.

    Declaration
    public override MergePolicy.MergeSpecification FindForcedDeletesMerges(SegmentInfos infos)
    Parameters
    Type Name Description
    SegmentInfos infos
    Returns
    Type Description
    MergePolicy.MergeSpecification
    Overrides
    MergePolicy.FindForcedDeletesMerges(SegmentInfos)

    FindForcedMerges(SegmentInfos, int, IDictionary<SegmentCommitInfo, bool>)

    Determine what set of merge operations is necessary in order to merge to <= the specified segment count. IndexWriter calls this when its ForceMerge(int, bool) method is called. This call is always synchronized on the IndexWriter instance so only one thread at a time will call this method.

    Declaration
    public override MergePolicy.MergeSpecification FindForcedMerges(SegmentInfos infos, int maxSegmentCount, IDictionary<SegmentCommitInfo, bool> segmentsToMerge)
    Parameters
    Type Name Description
    SegmentInfos infos
    int maxSegmentCount

    Requested maximum number of segments in the index (currently this is always 1)

    IDictionary<SegmentCommitInfo, bool> segmentsToMerge

    Contains the specific SegmentInfo instances that must be merged away. This may be a subset of all SegmentInfos. If the value is true for a given SegmentInfo, that means this segment was an original segment present in the to-be-merged index; else, it was a segment produced by a cascaded merge.

    Returns
    Type Description
    MergePolicy.MergeSpecification
    Overrides
    MergePolicy.FindForcedMerges(SegmentInfos, int, IDictionary<SegmentCommitInfo, bool>)

    FindMerges(MergeTrigger, SegmentInfos)

    Determine what set of merge operations are now necessary on the index. IndexWriter calls this whenever there is a change to the segments. This call is always synchronized on the IndexWriter instance so only one thread at a time will call this method.

    Declaration
    public override MergePolicy.MergeSpecification FindMerges(MergeTrigger mergeTrigger, SegmentInfos infos)
    Parameters
    Type Name Description
    MergeTrigger mergeTrigger

    the event that triggered the merge

    SegmentInfos infos
    Returns
    Type Description
    MergePolicy.MergeSpecification
    Overrides
    MergePolicy.FindMerges(MergeTrigger, SegmentInfos)

    Score(IList<SegmentCommitInfo>, bool, long)

    Expert: scores one merge; subclasses can override.

    Declaration
    protected virtual TieredMergePolicy.MergeScore Score(IList<SegmentCommitInfo> candidate, bool hitTooLarge, long mergingBytes)
    Parameters
    Type Name Description
    IList<SegmentCommitInfo> candidate
    bool hitTooLarge
    long mergingBytes
    Returns
    Type Description
    TieredMergePolicy.MergeScore

    ToString()

    Returns a string that represents the current object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents the current object.

    Overrides
    object.ToString()

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.