org.apache.lucene.index

## Class MergePolicy.OneMerge

- java.lang.Object
- - org.apache.lucene.index.MergePolicy.OneMerge

- Enclosing class:
    MergePolicy

      public static class MergePolicy.OneMerge
      extends Object

  OneMerge provides the information necessary to perform an individual primitive merge operation, resulting in a single new segment. The merge spec includes the subset of segments to be merged as well as whether the new segment should use the compound file format.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `long` | `estimatedMergeBytes` Estimated size in bytes of the merged segment.
    `MergeRateLimiter` | `rateLimiter` A private `RateLimiter` for this merge, used to rate limit writes and abort.
    `List<SegmentCommitInfo>` | `segments` Segments to be merged.
    `int` | `totalMaxDoc` Total number of documents in segments to be merged, not accounting for deletions.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MergePolicy.OneMerge(List<SegmentCommitInfo> segments)` Sole constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MergePolicy.DocMap` | `getDocMap(MergeState mergeState)` Expert: If `getMergeReaders()` reorders document IDs, this method must be overridden to return a mapping from the natural doc ID (the doc ID that would result from a natural merge) to the actual doc ID.
    `SegmentCommitInfo` | `getMergeInfo()` Returns the `SegmentCommitInfo` for the merged segment, or null if it hasn't been set yet.
    `List<CodecReader>` | `getMergeReaders()` Expert: Get the list of readers to merge.
    `MergeInfo` | `getStoreMergeInfo()` Return `MergeInfo` describing this merge.
    `void` | `mergeFinished()` Called by `IndexWriter` after the merge is done and all readers have been closed.
    `String` | `segString()` Returns a readable description of the current merge state.
    `void` | `setMergeInfo(SegmentCommitInfo info)` Expert: Sets the `SegmentCommitInfo` of the merged segment.
    `long` | `totalBytesSize()` Returns the total size in bytes of this merge.
    `int` | `totalNumDocs()` Returns the total number of documents that are included with this merge.

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

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

- - ### Field Detail

    - #### estimatedMergeBytes

          public volatile long estimatedMergeBytes

      Estimated size in bytes of the merged segment.

    - #### segments

          public final List<SegmentCommitInfo> segments

      Segments to be merged.

    - #### rateLimiter

          public final MergeRateLimiter rateLimiter

      A private `RateLimiter` for this merge, used to rate limit writes and abort.

    - #### totalMaxDoc

          public final int totalMaxDoc

      Total number of documents in segments to be merged, not accounting for deletions.

  - ### Constructor Detail

    - #### MergePolicy.OneMerge

          public MergePolicy.OneMerge(List<SegmentCommitInfo> segments)

      Sole constructor.
      Parameters:
        `segments` - List of `SegmentCommitInfo`s to be merged.

  - ### Method Detail

    - #### mergeFinished

          public void mergeFinished()
                             throws IOException

      Called by `IndexWriter` after the merge is done and all readers have been closed.
      Throws:
        `IOException`

    - #### getMergeReaders

          public List<CodecReader> getMergeReaders()
                                            throws IOException

      Expert: Get the list of readers to merge. Note that this list does not necessarily match the list of segments to merge and should only be used to feed SegmentMerger to initialize a merge. When a `MergePolicy.OneMerge` reorders doc IDs, it must override `getDocMap(org.apache.lucene.index.MergeState)` too so that deletes that happened during the merge can be applied to the newly merged segment.
      Throws:
        `IOException`

    - #### setMergeInfo

          public void setMergeInfo(SegmentCommitInfo info)

      Expert: Sets the `SegmentCommitInfo` of the merged segment. Allows sub-classes to e.g. set diagnostics properties.

    - #### getMergeInfo

          public SegmentCommitInfo getMergeInfo()

      Returns the `SegmentCommitInfo` for the merged segment, or null if it hasn't been set yet.

    - #### getDocMap

          public MergePolicy.DocMap getDocMap(MergeState mergeState)

      Expert: If `getMergeReaders()` reorders document IDs, this method must be overridden to return a mapping from the natural doc ID (the doc ID that would result from a natural merge) to the actual doc ID. This mapping is used to apply deletions that happened during the merge to the new segment.

    - #### segString

          public String segString()

      Returns a readable description of the current merge state.

    - #### totalBytesSize

          public long totalBytesSize()
                              throws IOException

      Returns the total size in bytes of this merge. Note that this does not indicate the size of the merged segment, but the input total size. This is only set once the merge is initialized by IndexWriter.
      Throws:
        `IOException`

    - #### totalNumDocs

          public int totalNumDocs()
                           throws IOException

      Returns the total number of documents that are included with this merge. Note that this does not indicate the number of documents after the merge.
      Throws:
        `IOException`

    - #### getStoreMergeInfo

          public MergeInfo getStoreMergeInfo()

      Return `MergeInfo` describing this merge.

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