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 and Description
    --- | ---
    `static interface` | `MergeScheduler.MergeSource` Provides access to new merges and executes the actual merge

  - ### Field Summary

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

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `close()` Close this MergeScheduler.
    `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 Detail

    - #### infoStream

          protected InfoStream infoStream

      For messages about merge scheduling

  - ### Constructor Detail

    - #### MergeScheduler

          protected MergeScheduler()

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

  - ### Method Detail

    - #### 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`.

    - #### close

          public abstract void close()
                              throws IOException

      Close this MergeScheduler.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      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.

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.