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.
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public class ConcurrentMergeScheduler : MergeScheduler, IConcurrentMergeScheduler, IMergeScheduler, IDisposableConstructors
| Improve this Doc View SourceConcurrentMergeScheduler()
Sole constructor, with all settings set to default values.
Declaration
public ConcurrentMergeScheduler()Fields
| Improve this Doc View SourcecompareByMergeDocCount
Sorts ConcurrentMergeScheduler.MergeThreads; larger merges come first.
Declaration
protected static readonly IComparer<ConcurrentMergeScheduler.MergeThread> compareByMergeDocCountField Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IComparer<ConcurrentMergeScheduler.MergeThread> | 
DEFAULT_MAX_MERGE_COUNT
Default MaxMergeCount.
Declaration
public const int DEFAULT_MAX_MERGE_COUNT = 2Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
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 = 1Field Value
| Type | Description | 
|---|---|
| System.Int32 | 
m_dir
Directory that holds the index.
Declaration
protected Directory m_dirField Value
| Type | Description | 
|---|---|
| Directory | 
m_mergeThreadCount
How many ConcurrentMergeScheduler.MergeThreads have kicked off (this is use to name them).
Declaration
protected int m_mergeThreadCountField Value
| Type | Description | 
|---|---|
| System.Int32 | 
m_mergeThreads
List of currently active ConcurrentMergeScheduler.MergeThreads.
Declaration
protected IList<ConcurrentMergeScheduler.MergeThread> m_mergeThreadsField Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IList<ConcurrentMergeScheduler.MergeThread> | 
m_writer
IndexWriter that owns this instance.
Declaration
protected IndexWriter m_writerField Value
| Type | Description | 
|---|---|
| IndexWriter | 
Properties
| Improve this Doc View SourceIsVerbose
Returns true if verbosing is enabled. This method is usually used in
conjunction with Message(String), like that:
if (IsVerbose) 
{
    Message("your message");
}Declaration
protected virtual bool IsVerbose { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
MaxMergeCount
Declaration
public virtual int MaxMergeCount { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
MaxThreadCount
Returns Lucene.Net.Index.ConcurrentMergeScheduler.maxThreadCount.
Declaration
public virtual int MaxThreadCount { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
See Also
| Improve this Doc View SourceMergeThreadCount
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 | 
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 SourceClearSuppressExceptions()
Used for testing
Declaration
public virtual void ClearSuppressExceptions()Clone()
Declaration
public override object Clone()Returns
| Type | Description | 
|---|---|
| System.Object | 
Overrides
| Improve this Doc View SourceDispose(Boolean)
Declaration
protected override void Dispose(bool disposing)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | disposing | 
Overrides
| Improve this Doc View SourceDoMerge(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 | 
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 | 
HandleMergeException(Exception)
Called when an exception is hit in a background merge thread
Declaration
protected virtual void HandleMergeException(Exception exc)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Exception | exc | 
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
| Improve this Doc View SourceMessage(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 | 
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  | 
| System.Int32 | maxThreadCount | The max # simultaneous merge threads that should
     be running at once.  This must be <=  | 
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 System.Threading.ThreadPriority.Highest(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 | 
SetSuppressExceptions()
Used for testing
Declaration
public virtual void SetSuppressExceptions()Sync()
Wait for any running merge threads to finish. This call is not interruptible as used by Dispose(Boolean).
Declaration
public virtual void Sync()ToString()
Declaration
public override string ToString()Returns
| Type | Description | 
|---|---|
| System.String | 
Overrides
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()