gate.creole.annic.apache.lucene.search
Class FieldDocSortedHitQueue

java.lang.Object
  extended by gate.creole.annic.apache.lucene.util.PriorityQueue
      extended by gate.creole.annic.apache.lucene.search.FieldDocSortedHitQueue

 class FieldDocSortedHitQueue
extends PriorityQueue

Expert: Collects sorted results from Searchable's and collates them. The elements put into this queue must be of type FieldDoc.

Created: Feb 11, 2004 2:04:21 PM

Since:
lucene 1.4
Version:
$Id: FieldDocSortedHitQueue.java 529 2004-10-05 11:55:26Z niraj $
Author:
Tim Jones (Nacimiento Software)

Field Summary
(package private)  Collator[] collators
           
(package private)  SortField[] fields
           
 
Constructor Summary
FieldDocSortedHitQueue(SortField[] fields, int size)
          Creates a hit queue sorted by the given list of fields.
 
Method Summary
(package private)  SortField[] getFields()
          Returns the fields being used to sort.
private  Collator[] hasCollators(SortField[] fields)
          Returns an array of collators, possibly null.
protected  boolean lessThan(Object a, Object b)
          Returns whether a is less relevant than b.
(package private)  void setFields(SortField[] fields)
          Allows redefinition of sort fields if they are null.
 
Methods inherited from class gate.creole.annic.apache.lucene.util.PriorityQueue
adjustTop, clear, initialize, insert, pop, put, size, top
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fields

volatile SortField[] fields

collators

volatile Collator[] collators
Constructor Detail

FieldDocSortedHitQueue

FieldDocSortedHitQueue(SortField[] fields,
                       int size)
                 throws IOException
Creates a hit queue sorted by the given list of fields.

Parameters:
fields - Field names, in priority order (highest priority first).
size - The number of hits to retain. Must be greater than zero.
Throws:
IOException
Method Detail

setFields

void setFields(SortField[] fields)
Allows redefinition of sort fields if they are null. This is to handle the case using ParallelMultiSearcher where the original list contains AUTO and we don't know the actual sort type until the values come back. The fields can only be set once. This method is thread safe.

Parameters:
fields -

getFields

SortField[] getFields()
Returns the fields being used to sort.


hasCollators

private Collator[] hasCollators(SortField[] fields)
Returns an array of collators, possibly null. The collators correspond to any SortFields which were given a specific locale.

Parameters:
fields - Array of sort fields.
Returns:
Array, possibly null.

lessThan

protected final boolean lessThan(Object a,
                                 Object b)
Returns whether a is less relevant than b.

Specified by:
lessThan in class PriorityQueue
Parameters:
a - ScoreDoc
b - ScoreDoc
Returns:
true if document a should be sorted after document b.