Package org.apache.lucene.index

# Class MergeScheduler

java.lang.Object
org.apache.lucene.index.MergeScheduler

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

Direct Known Subclasses:
  `ConcurrentMergeScheduler`, `NoMergeScheduler`, `SerialMergeScheduler`

public abstract class MergeScheduler extends Object implements Closeable
Expert: `IndexWriter` uses an instance implementing this interface to execute the merges selected by a `MergePolicy`. The default MergeScheduler is `ConcurrentMergeScheduler`.

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

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`MergeScheduler.MergeSource`
Provides access to new merges and executes the actual merge

## Field Summary

Fields
Modifier and Type
Field
Description
`protected InfoStream`
`infoStream`
For messages about merge scheduling

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`MergeScheduler()`
Sole constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Close this MergeScheduler.
`Executor`
`getIntraMergeExecutor(MergePolicy.OneMerge merge)`
Provides an executor for parallelism during a single merge operation.
`abstract void`
`merge(MergeScheduler.MergeSource mergeSource, MergeTrigger trigger)`
Run the merges provided by `MergeScheduler.MergeSource.getNextMerge()`.
`protected void`
`message(String message)`
Outputs the given message - this method assumes `verbose()` was called and returned true.
`protected boolean`
`verbose()`
Returns true if infoStream messages are enabled.
`Directory`
`wrapForMerge(MergePolicy.OneMerge merge, Directory in)`
Wraps the incoming `Directory` so that we can merge-throttle it using `RateLimitedIndexOutput`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### infoStream

protected InfoStream infoStream
For messages about merge scheduling

## Constructor Details

### MergeScheduler

protected MergeScheduler()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

## Method Details

### merge

public abstract void merge(MergeScheduler.MergeSource mergeSource, MergeTrigger trigger) throws IOException
Run the merges provided by `MergeScheduler.MergeSource.getNextMerge()`.

Parameters:
  `mergeSource` - the `IndexWriter` to obtain the merges from.
  `trigger` - the `MergeTrigger` that caused this merge to happen
Throws:
  `IOException`

### wrapForMerge

public Directory wrapForMerge(MergePolicy.OneMerge merge, Directory in)
Wraps the incoming `Directory` so that we can merge-throttle it using `RateLimitedIndexOutput`.

### getIntraMergeExecutor

public Executor getIntraMergeExecutor(MergePolicy.OneMerge merge)
Provides an executor for parallelism during a single merge operation. By default, the method returns a `SameThreadExecutorService` where all intra-merge actions occur in their calling thread.

### close

public void close() throws IOException
Close this MergeScheduler.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Throws:
  `IOException`

### verbose

protected boolean verbose()
Returns true if infoStream messages are enabled. This method is usually used in conjunction with `message(String)`:

     if (verbose()) {
       message("your message");
     }

### message

protected void message(String message)
Outputs the given message - this method assumes `verbose()` was called and returned true.