org.apache.lucene.chunk
Class SparseStringComparator.SparseComp

Object
  extended by SparseStringComparator.SparseComp
All Implemented Interfaces:
ScoreDocComparator
Enclosing class:
SparseStringComparator

private class SparseStringComparator.SparseComp
extends Object
implements ScoreDocComparator


Field Summary
(package private)  ArrayList entries
           
(package private)  boolean flipEmpty
           
 
Fields inherited from interface ScoreDocComparator
INDEXORDER, RELEVANCE
 
Constructor Summary
SparseStringComparator.SparseComp(IndexReader reader, String field)
           
 
Method Summary
 int compare(ScoreDoc d1, ScoreDoc d2)
          Compares two ScoreDoc objects and returns a result indicating their sort order.
private  SparseStringComparator.Entry findEntry(int docId)
          Retrieve the entry for a given document, or null if not found.
 int sortType()
          Returns the type of sort.
 Comparable sortValue(ScoreDoc i)
          Returns the value used to sort the given document.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entries

ArrayList entries

flipEmpty

boolean flipEmpty
Constructor Detail

SparseStringComparator.SparseComp

SparseStringComparator.SparseComp(IndexReader reader,
                                  String field)
                            throws IOException
Throws:
IOException
Method Detail

findEntry

private SparseStringComparator.Entry findEntry(int docId)
Retrieve the entry for a given document, or null if not found. Uses an efficient binary search over the array.


compare

public int compare(ScoreDoc d1,
                   ScoreDoc d2)
Compares two ScoreDoc objects and returns a result indicating their sort order.

Specified by:
compare in interface ScoreDocComparator
Parameters:
d1 - First ScoreDoc
d2 - Second ScoreDoc
Returns:
-1 if i should come before j
1 if i should come after j
0 if they are equal
See Also:
Comparator

sortValue

public Comparable sortValue(ScoreDoc i)
Returns the value used to sort the given document. The object returned must implement the java.io.Serializable interface. This is used by multisearchers to determine how to collate results from their searchers.

Specified by:
sortValue in interface ScoreDocComparator
Parameters:
i - Document
Returns:
Serializable object

sortType

public int sortType()
Returns the type of sort. Should return SortField.SCORE, SortField.DOC, SortField.STRING, SortField.INTEGER, SortField.FLOAT or SortField.CUSTOM. It is not valid to return SortField.AUTO. This is used by multisearchers to determine how to collate results from their searchers.

Specified by:
sortType in interface ScoreDocComparator
Returns:
One of the constants in SortField.
See Also:
SortField