public static final class

FieldComparator.ShortComparator

extends FieldComparator
java.lang.Object
   ↳ org.apache.lucene.search.FieldComparator
     ↳ org.apache.lucene.search.FieldComparator.ShortComparator

Class Overview

Parses field's values as short (using getShorts(IndexReader, String) and sorts by ascending value

Summary

Public Methods
int compare(int slot1, int slot2)
Compare hit at slot1 with hit at slot2.
int compareBottom(int doc)
Compare the bottom of the queue with doc.
void copy(int slot, int doc)
This method is called when a new hit is competitive.
void setBottom(int bottom)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue.
void setNextReader(IndexReader reader, int docBase)
Set a new Reader.
Comparable<?> value(int slot)
Return the actual value in the slot.
[Expand]
Inherited Methods
From class org.apache.lucene.search.FieldComparator
From class java.lang.Object

Public Methods

public int compare (int slot1, int slot2)

Compare hit at slot1 with hit at slot2.

Parameters
slot1 first slot to compare
slot2 second slot to compare
Returns
  • any N 0 if the slot2's value is sorted before slot1 and 0 if they are equal

public int compareBottom (int doc)

Compare the bottom of the queue with doc. This will only invoked after setBottom has been called. This should return the same result as compare(int, int)} as if bottom were slot1 and the new document were slot 2.

For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).

Parameters
doc that was hit
Returns
  • any N 0 if the doc's value is sorted before the bottom entry and 0 if they are equal.

public void copy (int slot, int doc)

This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.

Parameters
slot which slot to copy the hit to
doc docID relative to current reader

public void setBottom (int bottom)

Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When compareBottom(int) is called, you should compare against this slot. This will always be called before compareBottom(int).

Parameters
bottom the currently weakest (sorted last) slot in the queue

public void setNextReader (IndexReader reader, int docBase)

Set a new Reader. All doc correspond to the current Reader.

Parameters
reader current reader
docBase docBase of this reader
Throws
IOException

public Comparable<?> value (int slot)

Return the actual value in the slot.

Parameters
slot the value
Returns
  • value in this slot upgraded to Comparable