github.com/balzaczyy/golucene@v0.0.0-20151210033525-d0be9ee89713/core/search/model/docIdSetIterator.go (about)

     1  package model
     2  
     3  import (
     4  	"math"
     5  )
     6  
     7  const NO_MORE_DOCS = math.MaxInt32
     8  
     9  type DocIdSetIterator interface {
    10  	/**
    11  	 * Returns the following:
    12  	 * <ul>
    13  	 * <li>-1 or {@link #NO_MORE_DOCS} if {@link #nextDoc()} or
    14  	 * {@link #advance(int)} were not called yet.
    15  	 * <li>{@link #NO_MORE_DOCS} if the iterator has exhausted.
    16  	 * <li>Otherwise it should return the doc ID it is currently on.
    17  	 * </ul>
    18  	 * <p>
    19  	 *
    20  	 * @since 2.9
    21  	 */
    22  	DocId() int
    23  	/**
    24  	 * Advances to the next document in the set and returns the doc it is
    25  	 * currently on, or {@link #NO_MORE_DOCS} if there are no more docs in the
    26  	 * set.<br>
    27  	 *
    28  	 * <b>NOTE:</b> after the iterator has exhausted you should not call this
    29  	 * method, as it may result in unpredicted behavior.
    30  	 *
    31  	 * @since 2.9
    32  	 */
    33  	NextDoc() (doc int, err error)
    34  	/**
    35  	 * Advances to the first beyond the current whose document number is greater
    36  	 * than or equal to <i>target</i>, and returns the document number itself.
    37  	 * Exhausts the iterator and returns {@link #NO_MORE_DOCS} if <i>target</i>
    38  	 * is greater than the highest document number in the set.
    39  	 * <p>
    40  	 * The behavior of this method is <b>undefined</b> when called with
    41  	 * <code> target &le; current</code>, or after the iterator has exhausted.
    42  	 * Both cases may result in unpredicted behavior.
    43  	 * <p>
    44  	 * When <code> target &gt; current</code> it behaves as if written:
    45  	 *
    46  	 * <pre class="prettyprint">
    47  	 * int advance(int target) {
    48  	 *   int doc;
    49  	 *   while ((doc = nextDoc()) &lt; target) {
    50  	 *   }
    51  	 *   return doc;
    52  	 * }
    53  	 * </pre>
    54  	 *
    55  	 * Some implementations are considerably more efficient than that.
    56  	 * <p>
    57  	 * <b>NOTE:</b> this method may be called with {@link #NO_MORE_DOCS} for
    58  	 * efficiency by some Scorers. If your implementation cannot efficiently
    59  	 * determine that it should exhaust, it is recommended that you check for that
    60  	 * value in each call to this method.
    61  	 * <p>
    62  	 *
    63  	 * @since 2.9
    64  	 */
    65  	Advance(target int) (doc int, err error)
    66  	/**
    67  	 * Returns the estimated cost of this {@link DocIdSetIterator}.
    68  	 * <p>
    69  	 * This is generally an upper bound of the number of documents this iterator
    70  	 * might match, but may be a rough heuristic, hardcoded value, or otherwise
    71  	 * completely inaccurate.
    72  	 */
    73  	// Cost() int64
    74  }