Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.index.sorter
Class SortingMergePolicy

    java.lang.Object
      org.apache.lucene.index.MergePolicy
          org.apache.lucene.index.sorter.SortingMergePolicy

All Implemented Interfaces:
  Closeable, Cloneable

    public final class SortingMergePolicy

extends MergePolicy

A `MergePolicy` that reorders documents according to a `Sorter` before merging them. As a consequence, all segments resulting from a merge will be sorted while segments resulting from a flush will be in the order in which documents have been added.

NOTE: Never use this `MergePolicy` if you rely on `IndexWriter.addDocuments(Iterable, org.apache.lucene.analysis.Analyzer)` to have sequentially-assigned doc IDs, this policy will scatter doc IDs.

NOTE: This `MergePolicy` should only be used with idempotent `Sorter`s so that the order of segments is predictable. For example, using `SortingMergePolicy` with `Sorter.REVERSE_DOCS` (which is not idempotent) will make the order of documents in a segment depend on the number of times the segment has been merged.

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

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.lucene.index.MergePolicy
`MergePolicy.DocMap, MergePolicy.MergeAbortedException, MergePolicy.MergeException, MergePolicy.MergeSpecification, MergePolicy.MergeTrigger, MergePolicy.OneMerge`

Field Summary
`static String` | `SORTER_ID_PROP` Put in the `diagnostics` to denote that this segment is sorted.

Fields inherited from class org.apache.lucene.index.MergePolicy
`writer`

Constructor Summary
`SortingMergePolicy(MergePolicy in, Sorter sorter)` Create a new `MergePolicy` that sorts documents with `sorter`.

Method Summary
`MergePolicy` | `clone()`
`void` | `close()`
`MergePolicy.MergeSpecification` | `findForcedDeletesMerges(SegmentInfos segmentInfos)`
`MergePolicy.MergeSpecification` | `findForcedMerges(SegmentInfos segmentInfos, int maxSegmentCount, Map<SegmentInfoPerCommit,Boolean> segmentsToMerge)`
`MergePolicy.MergeSpecification` | `findMerges(MergePolicy.MergeTrigger mergeTrigger, SegmentInfos segmentInfos)`
`static boolean` | `isSorted(AtomicReader reader, Sorter sorter)` Returns true if the given reader is sorted by the given sorter.
`void` | `setIndexWriter(IndexWriter writer)`
`String` | `toString()`
`boolean` | `useCompoundFile(SegmentInfos segments, SegmentInfoPerCommit newSegment)`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### SORTER_ID_PROP

    public static final String SORTER_ID_PROP

  Put in the `diagnostics` to denote that this segment is sorted.

  See Also:
    Constant Field Values

Constructor Detail

### SortingMergePolicy

    public SortingMergePolicy(MergePolicy in,
                              Sorter sorter)

  Create a new `MergePolicy` that sorts documents with `sorter`.

Method Detail

### isSorted

    public static boolean isSorted(AtomicReader reader,
                                   Sorter sorter)

  Returns true if the given reader is sorted by the given sorter.

### findMerges

    public MergePolicy.MergeSpecification findMerges(MergePolicy.MergeTrigger mergeTrigger,
                                                     SegmentInfos segmentInfos)
                                              throws IOException

  Specified by:
    `findMerges` in class `MergePolicy`
  Throws:
    `IOException`

### findForcedMerges

    public MergePolicy.MergeSpecification findForcedMerges(SegmentInfos segmentInfos,
                                                           int maxSegmentCount,
                                                           Map<SegmentInfoPerCommit,Boolean> segmentsToMerge)
                                                    throws IOException

  Specified by:
    `findForcedMerges` in class `MergePolicy`
  Throws:
    `IOException`

### findForcedDeletesMerges

    public MergePolicy.MergeSpecification findForcedDeletesMerges(SegmentInfos segmentInfos)
                                                           throws IOException

  Specified by:
    `findForcedDeletesMerges` in class `MergePolicy`
  Throws:
    `IOException`

### clone

    public MergePolicy clone()

  Overrides:
    `clone` in class `MergePolicy`

### close

    public void close()

  Specified by:
    `close` in interface `Closeable`
  Specified by:
    `close` in class `MergePolicy`

### useCompoundFile

    public boolean useCompoundFile(SegmentInfos segments,
                                   SegmentInfoPerCommit newSegment)
                            throws IOException

  Specified by:
    `useCompoundFile` in class `MergePolicy`
  Throws:
    `IOException`

### setIndexWriter

    public void setIndexWriter(IndexWriter writer)

  Overrides:
    `setIndexWriter` in class `MergePolicy`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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