com.atlassian.jira.issue.search.parameters.lucene.sort
Class MappedSortComparator

java.lang.Object
  extended by com.atlassian.jira.issue.search.parameters.lucene.sort.MappedSortComparator
All Implemented Interfaces:
java.io.Serializable, org.apache.lucene.search.SortComparatorSource

public class MappedSortComparator
extends java.lang.Object
implements org.apache.lucene.search.SortComparatorSource

This Sort Comparator reads through the terms dictionary in lucene, and builds up a list of ordered terms. It then sorts the documents according to the order that they appear in the terms list.

This approach, whilst very fast, does load the entire term dictionary into memory. This could be a problem where there are a large number of terms (eg. text fields).

See Also:
Serialized Form

Constructor Summary
MappedSortComparator(LuceneFieldSorter sorter)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object getComparable(java.lang.String termtext)
          Returns an object which, when sorted according by the comparator returned from LuceneFieldSorter.getComparator() , will order the Term values in the correct order.
 java.util.Comparator getComparator()
           
 int hashCode()
           
 org.apache.lucene.search.ScoreDocComparator newComparator(org.apache.lucene.index.IndexReader reader, java.lang.String fieldname)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappedSortComparator

public MappedSortComparator(LuceneFieldSorter sorter)
Method Detail

newComparator

public org.apache.lucene.search.ScoreDocComparator newComparator(org.apache.lucene.index.IndexReader reader,
                                                                 java.lang.String fieldname)
                                                          throws java.io.IOException
Specified by:
newComparator in interface org.apache.lucene.search.SortComparatorSource
Throws:
java.io.IOException

getComparable

public java.lang.Object getComparable(java.lang.String termtext)
Returns an object which, when sorted according by the comparator returned from LuceneFieldSorter.getComparator() , will order the Term values in the correct order.

For example, if the Terms contained integer values, this method would return new Integer(termtext). Note that this might not always be the most efficient implementation - for this particular example, a better implementation might be to make a ScoreDocLookupComparator that uses an internal lookup table of int.

Parameters:
termtext - The textual value of the term.
Returns:
An object representing termtext that can be sorted by LuceneFieldSorter.getComparator()
See Also:
Comparable, ScoreDocComparator

getComparator

public java.util.Comparator getComparator()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2002-2010 Atlassian. All Rights Reserved.