org.galagosearch.tupleflow
Interface Order<T>

Type Parameters:
T - The ordered class.

public interface Order<T>

An Order is a class that represents an ordering of a Galago Type. You won't usually implement this interface directly; instead, let Galago make the class for you with the TemplateTypeBuilder/TypeBuilderMojo tools.

Author:
trevor

Method Summary
 java.lang.Class<T> getOrderedClass()
           
 java.lang.String[] getOrderSpec()
          Returns a string representation of the fields ordered by this class.
 java.util.Comparator<T> greaterThan()
          lessThan().compare(a,b) = greaterThan().compare(b,a);
 int hash(T object)
          This is a hash function over an object that only uses ordered fields.
 java.util.Comparator<T> lessThan()
          Returns a comparator that applies this order to objects of type T.
 ReaderSource<T> orderedCombiner(java.util.Collection<TypeReader<T>> readers, boolean closeOnExit)
          Produces an OrderedCombiner object.
 TypeReader<T> orderedReader(ArrayInput input)
          Produces an OrderedReader object.
 TypeReader<T> orderedReader(ArrayInput input, int bufferSize)
          Produces an OrderedReader object.
 Processor<T> orderedWriter(ArrayOutput output)
          Produces an OrderedWriter object that can write objects of class T in this order.
 

Method Detail

getOrderedClass

java.lang.Class<T> getOrderedClass()

getOrderSpec

java.lang.String[] getOrderSpec()
Returns a string representation of the fields ordered by this class. For example:
{ "+document", "-score" }
means that this order orders first by the document number in ascending order, but breaks ties by the score in descending order.


lessThan

java.util.Comparator<T> lessThan()
Returns a comparator that applies this order to objects of type T. For example, if
getOrderSpec() == { "+document" }
and a.document = 5 and b.document = 7, then:
lessThan().compare(a, b) < 0
.


greaterThan

java.util.Comparator<T> greaterThan()
lessThan().compare(a,b) = greaterThan().compare(b,a);


hash

int hash(T object)
This is a hash function over an object that only uses ordered fields. For instance, if the order is
{ "+document", "-score" }
, this hash function incorporates data from the document and score fields, but no other fields.

Parameters:
object -
Returns:

orderedWriter

Processor<T> orderedWriter(ArrayOutput output)
Produces an OrderedWriter object that can write objects of class T in this order. This object assumes that its input is already correctly ordered. The OrderedWriter uses the ordering property to write the data in compressed form.

Parameters:
output -
Returns:

orderedReader

TypeReader<T> orderedReader(ArrayInput input)
Produces an OrderedReader object. This object can read objects that were written with an OrderedWriter object produced by the Order.orderedWriter method.

Parameters:
input -
Returns:

orderedReader

TypeReader<T> orderedReader(ArrayInput input,
                            int bufferSize)
Produces an OrderedReader object. This is just like the previous orderedReader method, except you can explicitly set a buffer size.

Parameters:
input -
bufferSize -
Returns:

orderedCombiner

ReaderSource<T> orderedCombiner(java.util.Collection<TypeReader<T>> readers,
                                boolean closeOnExit)
Produces an OrderedCombiner object. An ordered combiner merges objects from many OrderedReaders into a single ordered stream of objects.

Parameters:
readers -
closeOnExit -
Returns:


Copyright © 2009. All Rights Reserved.