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 EarlyTerminatingSortingCollector

    java.lang.Object
      org.apache.lucene.search.Collector
          org.apache.lucene.index.sorter.EarlyTerminatingSortingCollector

    public class EarlyTerminatingSortingCollector

extends Collector

A `Collector` that early terminates collection of documents on a per-segment basis, if the segment was sorted according to the given `Sorter`.

NOTE: the `Collector` detects sorted segments according to `SortingMergePolicy`, so it's best used in conjunction with it. Also, it collects up to a specified num docs from each segment, and therefore is mostly suitable for use in conjunction with collectors such as `TopDocsCollector`, and not e.g. `TotalHitCountCollector`.

NOTE: If you wrap a `TopDocsCollector` that sorts in the same order as the index order, the returned `TopDocsCollector.topDocs()` will be correct. However the total of `hit count` will be underestimated since not all matching documents will have been collected.

NOTE: This `Collector` uses `Sorter.getID()` to detect whether a segment was sorted with the same `Sorter` as the one given in `EarlyTerminatingSortingCollector(Collector, Sorter, int)`. This has two implications:

- if `Sorter.getID()` is not implemented correctly and returns different identifiers for equivalent `Sorter`s, this collector will not detect sorted segments,
- if you suddenly change the `IndexWriter`'s `SortingMergePolicy` to sort according to another criterion and if both the old and the new `Sorter`s have the same identifier, this `Collector` will incorrectly detect sorted segments.

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

Field Summary
`protected Collector` | `in`
`protected int` | `numDocsToCollect`
`protected boolean` | `segmentSorted`
`protected int` | `segmentTotalCollect`
`protected Sorter` | `sorter`

Constructor Summary
`EarlyTerminatingSortingCollector(Collector in, Sorter sorter, int numDocsToCollect)` Create a new `EarlyTerminatingSortingCollector` instance.

Method Summary
`boolean` | `acceptsDocsOutOfOrder()`
`void` | `collect(int doc)`
`void` | `setNextReader(AtomicReaderContext context)`
`void` | `setScorer(Scorer scorer)`

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

Field Detail

### in

    protected final Collector in

### sorter

    protected final Sorter sorter

### numDocsToCollect

    protected final int numDocsToCollect

### segmentTotalCollect

    protected int segmentTotalCollect

### segmentSorted

    protected boolean segmentSorted

Constructor Detail

### EarlyTerminatingSortingCollector

    public EarlyTerminatingSortingCollector(Collector in,
                                            Sorter sorter,
                                            int numDocsToCollect)

  Create a new `EarlyTerminatingSortingCollector` instance.

  Parameters:
    `in` - the collector to wrap
    `sorter` - the same sorter as the one which is used by `IndexWriter`'s `SortingMergePolicy`
    `numDocsToCollect` - the number of documents to collect on each segment. When wrapping a `TopDocsCollector`, this number should be the number of hits.

Method Detail

### setScorer

    public void setScorer(Scorer scorer)
                   throws IOException

  Specified by:
    `setScorer` in class `Collector`
  Throws:
    `IOException`

### collect

    public void collect(int doc)
                 throws IOException

  Specified by:
    `collect` in class `Collector`
  Throws:
    `IOException`

### setNextReader

    public void setNextReader(AtomicReaderContext context)
                       throws IOException

  Specified by:
    `setNextReader` in class `Collector`
  Throws:
    `IOException`

### acceptsDocsOutOfOrder

    public boolean acceptsDocsOutOfOrder()

  Specified by:
    `acceptsDocsOutOfOrder` in class `Collector`

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.