Show / Hide Table of Contents

    Class ConcurrentMergeScheduler

    A MergeScheduler that runs each merge using a separate thread.

    Specify the max number of threads that may run at once, and the maximum number of simultaneous merges with SetMaxMergesAndThreads(Int32, Int32).

    If the number of merges exceeds the max number of threads then the largest merges are paused until one of the smaller merges completes.

    If more than MaxMergeCount merges are requested then this class will forcefully throttle the incoming threads by pausing until one more more merges complete.

    Inheritance
    System.Object
    MergeScheduler
    ConcurrentMergeScheduler
    Implements
    IConcurrentMergeScheduler
    IMergeScheduler
    IDisposable
    Inherited Members
    MergeScheduler.Dispose()
    Namespace: Lucene.Net.Index
    Assembly: Lucene.Net.dll
    Syntax
    public class ConcurrentMergeScheduler : MergeScheduler, IConcurrentMergeScheduler, IMergeScheduler, IDisposable

    Constructors

    | Improve this Doc View Source

    ConcurrentMergeScheduler()

    Sole constructor, with all settings set to default values.

    Declaration
    public ConcurrentMergeScheduler()

    Fields

    | Improve this Doc View Source

    compareByMergeDocCount

    Sorts ConcurrentMergeScheduler.MergeThreads; larger merges come first.

    Declaration
    protected static readonly IComparer<ConcurrentMergeScheduler.MergeThread> compareByMergeDocCount
    Field Value
    Type Description
    IComparer<ConcurrentMergeScheduler.MergeThread>
    | Improve this Doc View Source

    DEFAULT_MAX_MERGE_COUNT

    Default MaxMergeCount.

    Declaration
    public const int DEFAULT_MAX_MERGE_COUNT = null
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    DEFAULT_MAX_THREAD_COUNT

    Default MaxThreadCount. We default to 1: tests on spinning-magnet drives showed slower indexing performance if more than one merge thread runs at once (though on an SSD it was faster)

    Declaration
    public const int DEFAULT_MAX_THREAD_COUNT = null
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    m_dir

    Directory that holds the index.

    Declaration
    protected Directory m_dir
    Field Value
    Type Description
    Directory
    | Improve this Doc View Source

    m_mergeThreadCount

    How many ConcurrentMergeScheduler.MergeThreads have kicked off (this is use to name them).

    Declaration
    protected int m_mergeThreadCount
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    m_mergeThreads

    List of currently active ConcurrentMergeScheduler.MergeThreads.

    Declaration
    protected IList<ConcurrentMergeScheduler.MergeThread> m_mergeThreads
    Field Value
    Type Description
    IList<ConcurrentMergeScheduler.MergeThread>
    | Improve this Doc View Source

    m_writer

    IndexWriter that owns this instance.

    Declaration
    protected IndexWriter m_writer
    Field Value
    Type Description
    IndexWriter

    Properties

    | Improve this Doc View Source

    IsVerbose

    Returns true if verbosing is enabled. This method is usually used in conjunction with , like that:

    if (IsVerbose) 
    {
        Message("your message");
    }
    Declaration
    protected virtual bool IsVerbose { get; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MaxMergeCount

    See SetMaxMergesAndThreads(Int32, Int32).

    Declaration
    public virtual int MaxMergeCount { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MaxThreadCount

    Returns Lucene.Net.Index.ConcurrentMergeScheduler.maxThreadCount.

    Declaration
    public virtual int MaxThreadCount { get; }
    Property Value
    Type Description
    System.Int32
    See Also
    SetMaxMergesAndThreads(Int32, Int32)
    | Improve this Doc View Source

    MergeThreadCount

    Returns the number of merge threads that are alive. Note that this number is <= m_mergeThreads size.

    Declaration
    protected virtual int MergeThreadCount { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    MergeThreadPriority

    Return the priority that merge threads run at. By default the priority is 1 plus the priority of (ie, slightly higher priority than) the first thread that calls merge.

    Declaration
    public virtual int MergeThreadPriority { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    ClearSuppressExceptions()

    Used for testing

    Declaration
    public virtual void ClearSuppressExceptions()
    | Improve this Doc View Source

    Clone()

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object
    Overrides
    MergeScheduler.Clone()
    | Improve this Doc View Source

    Dispose(Boolean)

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    MergeScheduler.Dispose(Boolean)
    | Improve this Doc View Source

    DoMerge(MergePolicy.OneMerge)

    Does the actual merge, by calling Merge(MergePolicy.OneMerge)

    Declaration
    protected virtual void DoMerge(MergePolicy.OneMerge merge)
    Parameters
    Type Name Description
    MergePolicy.OneMerge merge
    | Improve this Doc View Source

    GetMergeThread(IndexWriter, MergePolicy.OneMerge)

    Create and return a new ConcurrentMergeScheduler.MergeThread

    Declaration
    protected virtual ConcurrentMergeScheduler.MergeThread GetMergeThread(IndexWriter writer, MergePolicy.OneMerge merge)
    Parameters
    Type Name Description
    IndexWriter writer
    MergePolicy.OneMerge merge
    Returns
    Type Description
    ConcurrentMergeScheduler.MergeThread
    | Improve this Doc View Source

    HandleMergeException(Exception)

    Called when an exception is hit in a background merge thread

    Declaration
    protected virtual void HandleMergeException(Exception exc)
    Parameters
    Type Name Description
    Exception exc
    | Improve this Doc View Source

    Merge(IndexWriter, MergeTrigger, Boolean)

    Declaration
    public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound)
    Parameters
    Type Name Description
    IndexWriter writer
    MergeTrigger trigger
    System.Boolean newMergesFound
    Overrides
    MergeScheduler.Merge(IndexWriter, MergeTrigger, Boolean)
    | Improve this Doc View Source

    Message(String)

    Outputs the given message - this method assumes IsVerbose was called and returned true.

    Declaration
    protected virtual void Message(string message)
    Parameters
    Type Name Description
    System.String message
    | Improve this Doc View Source

    SetMaxMergesAndThreads(Int32, Int32)

    Sets the maximum number of merge threads and simultaneous merges allowed.

    Declaration
    public virtual void SetMaxMergesAndThreads(int maxMergeCount, int maxThreadCount)
    Parameters
    Type Name Description
    System.Int32 maxMergeCount

    the max # simultaneous merges that are allowed. If a merge is necessary yet we already have this many threads running, the incoming thread (that is calling add/updateDocument) will block until a merge thread has completed. Note that we will only run the smallest maxThreadCount merges at a time.

    System.Int32 maxThreadCount

    The max # simultaneous merge threads that should be running at once. This must be <= maxMergeCount

    | Improve this Doc View Source

    SetMergeThreadPriority(Int32)

    Set the base priority that merge threads run at. Note that CMS may increase priority of some merge threads beyond this base priority. It's best not to set this any higher than (4)-maxThreadCount, so that CMS has room to set relative priority among threads.

    Declaration
    public virtual void SetMergeThreadPriority(int priority)
    Parameters
    Type Name Description
    System.Int32 priority
    | Improve this Doc View Source

    SetSuppressExceptions()

    Used for testing

    Declaration
    public virtual void SetSuppressExceptions()
    | Improve this Doc View Source

    Sync()

    Wait for any running merge threads to finish. This call is not interruptible as used by Dispose(Boolean).

    Declaration
    public virtual void Sync()
    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    UpdateMergeThreads()

    Called whenever the running merges have changed, to pause & unpause threads. This method sorts the merge threads by their merge size in descending order and then pauses/unpauses threads from first to last -- that way, smaller merges are guaranteed to run before larger ones.

    Declaration
    protected virtual void UpdateMergeThreads()

    Implements

    IConcurrentMergeScheduler
    IMergeScheduler
    IDisposable
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)