Module org.apache.lucene.core
Package org.apache.lucene.search
Class FieldValueHitQueue<T extends FieldValueHitQueue.Entry>
- java.lang.Object
-
- org.apache.lucene.util.PriorityQueue<T>
-
- org.apache.lucene.search.FieldValueHitQueue<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
- Direct Known Subclasses:
FieldValueHitQueue.MultiComparatorsFieldValueHitQueue
,FieldValueHitQueue.OneComparatorFieldValueHitQueue
public abstract class FieldValueHitQueue<T extends FieldValueHitQueue.Entry> extends PriorityQueue<T>
Expert: A hit queue for sorting by hits by terms in more than one field.- Since:
- 2.9
- See Also:
IndexSearcher.search(Query,int,Sort)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FieldValueHitQueue.Entry
Extension of ScoreDoc to also store theFieldComparator
slot.private static class
FieldValueHitQueue.MultiComparatorsFieldValueHitQueue<T extends FieldValueHitQueue.Entry>
An implementation ofFieldValueHitQueue
which is optimized in case there is more than one comparator.private static class
FieldValueHitQueue.OneComparatorFieldValueHitQueue<T extends FieldValueHitQueue.Entry>
An implementation ofFieldValueHitQueue
which is optimized in case there is just one comparator.
-
Field Summary
Fields Modifier and Type Field Description protected FieldComparator<?>[]
comparators
protected SortField[]
fields
Stores the sort criteria being used.protected int[]
reverseMul
-
Constructor Summary
Constructors Modifier Constructor Description private
FieldValueHitQueue(SortField[] fields, int size)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T extends FieldValueHitQueue.Entry>
FieldValueHitQueue<T>create(SortField[] fields, int size)
Creates a hit queue sorted by the given list of fields.(package private) FieldDoc
fillFields(FieldValueHitQueue.Entry entry)
Given a queue Entry, creates a corresponding FieldDoc that contains the values used to sort the given document.FieldComparator<?>[]
getComparators()
LeafFieldComparator[]
getComparators(LeafReaderContext context)
(package private) SortField[]
getFields()
Returns the SortFields being used by this hit queue.int[]
getReverseMul()
protected abstract boolean
lessThan(FieldValueHitQueue.Entry a, FieldValueHitQueue.Entry b)
Determines the ordering of objects in this priority queue.-
Methods inherited from class org.apache.lucene.util.PriorityQueue
add, addAll, clear, getHeapArray, insertWithOverflow, iterator, pop, remove, size, top, updateTop, updateTop
-
-
-
-
Field Detail
-
fields
protected final SortField[] fields
Stores the sort criteria being used.
-
comparators
protected final FieldComparator<?>[] comparators
-
reverseMul
protected final int[] reverseMul
-
-
Constructor Detail
-
FieldValueHitQueue
private FieldValueHitQueue(SortField[] fields, int size)
-
-
Method Detail
-
create
public static <T extends FieldValueHitQueue.Entry> FieldValueHitQueue<T> create(SortField[] fields, int size)
Creates a hit queue sorted by the given list of fields.NOTE: The instances returned by this method pre-allocate a full array of length
numHits
.- Parameters:
fields
- SortField array we are sorting by in priority order (highest priority first); cannot benull
or emptysize
- The number of hits to retain. Must be greater than zero.
-
getComparators
public FieldComparator<?>[] getComparators()
-
getReverseMul
public int[] getReverseMul()
-
getComparators
public LeafFieldComparator[] getComparators(LeafReaderContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
lessThan
protected abstract boolean lessThan(FieldValueHitQueue.Entry a, FieldValueHitQueue.Entry b)
Description copied from class:PriorityQueue
Determines the ordering of objects in this priority queue. Subclasses must define this one method.- Specified by:
lessThan
in classPriorityQueue<T extends FieldValueHitQueue.Entry>
- Returns:
true
iff parametera
is less than parameterb
.
-
fillFields
FieldDoc fillFields(FieldValueHitQueue.Entry entry)
Given a queue Entry, creates a corresponding FieldDoc that contains the values used to sort the given document. These values are not the raw values out of the index, but the internal representation of them. This is so the given search hit can be collated by a MultiSearcher with other search hits.- Parameters:
entry
- The Entry used to create a FieldDoc- Returns:
- The newly created FieldDoc
- See Also:
IndexSearcher.search(Query,int,Sort)
-
getFields
SortField[] getFields()
Returns the SortFields being used by this hit queue.
-
-