com.sun.labs.minion.retrieval
Class ResultImpl

java.lang.Object
  extended by com.sun.labs.minion.retrieval.ResultImpl
All Implemented Interfaces:
Result, ResultAccessor, java.lang.Cloneable, java.lang.Comparable<Result>

public class ResultImpl
extends java.lang.Object
implements Result, java.lang.Comparable<Result>, java.lang.Cloneable, ResultAccessor


Field Summary
protected  ArrayGroup ag
          The array group containing this result.
protected  int doc
          The ID of the document containing the hit.
protected  QueryElement el
          The query that generated this result.
protected  java.lang.Object[] fields
          The field values used to sort this document.
protected static java.lang.String logTag
           
protected  java.util.Map passages
          A map from field names to the passage stores for those fields.
protected  QueryStats qs
          A set of query statistics.
protected  float score
          The score the docuemnt received.
protected  ResultSet set
          The set of results to which this result belongs.
protected  SortSpec sortSpec
          The sorting specification for this result.
 
Constructor Summary
ResultImpl()
          Creates an empty search result.
ResultImpl(ResultSet set, ArrayGroup ag, SortSpec sortSpec, int doc, float score)
          Creates a search result.
 
Method Summary
 java.lang.Object clone()
          Clones this group.
 int compareTo(Result o)
           
 boolean equals(java.lang.Object o)
          Two results are equal if they represent the same document.
 boolean[] getDirections()
           
 double[] getDistance(java.util.List l, java.lang.String name)
           
 double getDistance(Result r, java.lang.String name)
          Gets the distance between this result and another based on a named feature vector value.
 int getDocID()
           
 Document getDocument()
          Gets a document abstraction for the document in this result.
 DocumentVector getDocumentVector()
          Gets the document vector corresponding to this result.
 DocumentVector getDocumentVector(java.lang.String field)
          Gets the document vector corresponding to this result.
 DocumentVector getDocumentVector(WeightedField[] fields)
          Gets a composite document vector that corresponds to a linear combination of a number of vectored fields in the document in this result.
 SearchEngine getEngine()
           
 java.util.List getField(java.lang.String name)
          Gets the value of the saved field from the field store.
 java.util.Iterator getFieldIterator()
          Returns an iterator for all of the field values in a result.
protected  void getFieldValue(int i)
          Gets a single field value, suitable for use in sorting results.
 java.lang.String getIndexName()
          Gets the name of the index that this hit was drawn from.
 java.lang.String getKey()
          Gets the document key associated with the document represented by this result.
 DocKeyEntry getKeyEntry()
          Gets the document key entry associated with this document.
 int getNPassages()
          Gets the number of passages associated with this result.
 DiskPartition getPart()
           
 int getPartNum()
           
 PassageBuilder getPassageBuilder()
          Gets a passage builder for this result.
 float getScore()
          Gets the score associated with this result.
 java.lang.Object getSingleFieldValue(java.lang.String name)
          Gets a single value of a saved field for the document.
 SortSpec getSortSpec()
           
 java.lang.Object[] getSortVals()
           
protected  void init(ResultSet set, ArrayGroup ag, SortSpec sortSpec, int doc, float score)
          Initializes the members of this result.
protected  void setFields()
           
 void setQueryStats(QueryStats qs)
           
 void setScore(float score)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

set

protected ResultSet set
The set of results to which this result belongs.


ag

protected ArrayGroup ag
The array group containing this result.


el

protected QueryElement el
The query that generated this result.


doc

protected int doc
The ID of the document containing the hit.


score

protected float score
The score the docuemnt received.


sortSpec

protected SortSpec sortSpec
The sorting specification for this result.


passages

protected java.util.Map passages
A map from field names to the passage stores for those fields. Used for passage highlighting.


fields

protected java.lang.Object[] fields
The field values used to sort this document.


qs

protected QueryStats qs
A set of query statistics.


logTag

protected static java.lang.String logTag
Constructor Detail

ResultImpl

public ResultImpl()
Creates an empty search result.


ResultImpl

public ResultImpl(ResultSet set,
                  ArrayGroup ag,
                  SortSpec sortSpec,
                  int doc,
                  float score)
Creates a search result.

Parameters:
set - The set of results to which this result belongs.
ag - the array group to which this result belongs
sortSpec - the sort order being applied to the result set
doc - The document ID for the hit.
score - The score the document received.
Method Detail

init

protected void init(ResultSet set,
                    ArrayGroup ag,
                    SortSpec sortSpec,
                    int doc,
                    float score)
Initializes the members of this result. Needed so that we can refill results rather than generating new ones when processing large document sets.

Parameters:
set - The set of results to which this result belongs.
ag - the array group to which this result belongs
sortSpec - the sort order being applied to the result set
doc - The document ID for the hit.
score - The score the document received.

getKeyEntry

public DocKeyEntry getKeyEntry()
Gets the document key entry associated with this document.

Returns:
the doc key entry

getKey

public java.lang.String getKey()
Gets the document key associated with the document represented by this result.

Specified by:
getKey in interface Result
Specified by:
getKey in interface ResultAccessor
Returns:
the key for the document represented by this result

getField

public java.util.List getField(java.lang.String name)
Gets the value of the saved field from the field store.

Specified by:
getField in interface Result
Specified by:
getField in interface ResultAccessor
Parameters:
name - The name of the field for which we want the saved values.
Returns:
an Object of the appropriate type.

getSingleFieldValue

public java.lang.Object getSingleFieldValue(java.lang.String name)
Description copied from interface: Result
Gets a single value of a saved field for the document.

Specified by:
getSingleFieldValue in interface Result
Specified by:
getSingleFieldValue in interface ResultAccessor
Parameters:
name - The name of the field for which we want the saved values.
Returns:
An object of the appropriate type for the named field. If multiple values are stored for the named field, no guarantee is made about which of the multiple values are returned. If the given name does not name a saved field or if there was no data stored for that field, then null is returned.

getDocument

public Document getDocument()
Description copied from interface: Result
Gets a document abstraction for the document in this result.

Specified by:
getDocument in interface Result
Returns:
the document abstraction corresponding to this result.

getDocumentVector

public DocumentVector getDocumentVector()
Gets the document vector corresponding to this result. The document vector will be built from data for all the vectored fields in the document.

Specified by:
getDocumentVector in interface Result
Returns:
the document vector for the document represented by this result

getDocumentVector

public DocumentVector getDocumentVector(java.lang.String field)
Gets the document vector corresponding to this result.

Specified by:
getDocumentVector in interface Result
Parameters:
field - the name of a vectored field upon which the clustering should be based. A value of null indicates that all vectored fields should be considered, while an empty string indicates that data in no explicit field should be considered.
Returns:
the document vector for this document where the terms in the vector are those found only in the given field. Note that the document vector returned cannot be used in conjunction with a composite document vector.
See Also:
Result.getDocumentVector(WeightedField[])

getDocumentVector

public DocumentVector getDocumentVector(WeightedField[] fields)
Description copied from interface: Result
Gets a composite document vector that corresponds to a linear combination of a number of vectored fields in the document in this result. The linear combination of the components of the document vector is described by the weighted fields provided. While not an absolute necessity, if the weights of the fields do not sum to 1, you may get a document vector with weights greater than 1.

Specified by:
getDocumentVector in interface Result
Parameters:
fields - the fields that we will be using to build the document vector
Returns:
the composite document vector for this document where the terms in the vector are those found in any of the provided fields. Note that the document vector returned cannot be used in conjunction with a non-composite document vector!
See Also:
Result.getDocumentVector(String)

getFieldIterator

public java.util.Iterator getFieldIterator()
Returns an iterator for all of the field values in a result.

Specified by:
getFieldIterator in interface Result
Returns:
an iterator for all of the field values in a result

getScore

public float getScore()
Gets the score associated with this result.

Specified by:
getScore in interface Result
Specified by:
getScore in interface ResultAccessor
Returns:
the score associated with this result

setScore

public void setScore(float score)

setQueryStats

public void setQueryStats(QueryStats qs)

getDistance

public double getDistance(Result r,
                          java.lang.String name)
Gets the distance between this result and another based on a named feature vector value.

Specified by:
getDistance in interface Result
Parameters:
r - the other result
name - the name of the feature vector field
Returns:
the euclidean distance between the two results based on the give field.

getDistance

public double[] getDistance(java.util.List l,
                            java.lang.String name)

getDocID

public int getDocID()

getPartNum

public int getPartNum()

getPart

public DiskPartition getPart()

getNPassages

public int getNPassages()
Gets the number of passages associated with this result.

Specified by:
getNPassages in interface Result
Returns:
the number of passages associated with this result.

getIndexName

public java.lang.String getIndexName()
Gets the name of the index that this hit was drawn from. This is a configuration parameter that is passed to the SearchEngine at startup time.

Specified by:
getIndexName in interface Result
Returns:
the name of the index from which this result was drawn

getPassageBuilder

public PassageBuilder getPassageBuilder()
Gets a passage builder for this result. This will find the actual. passages.

Specified by:
getPassageBuilder in interface Result
Returns:
null if there are no query terms suitable for passage highlighting.

getFieldValue

protected void getFieldValue(int i)
Gets a single field value, suitable for use in sorting results.

Parameters:
i - The index of the field in our sort specification whose value we want to retrieve.

setFields

protected void setFields()

compareTo

public int compareTo(Result o)
Specified by:
compareTo in interface java.lang.Comparable<Result>

equals

public boolean equals(java.lang.Object o)
Two results are equal if they represent the same document.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to test for equality
Returns:
true if the receiver and the argument are equal, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEngine

public SearchEngine getEngine()

getSortSpec

public SortSpec getSortSpec()

getDirections

public boolean[] getDirections()

getSortVals

public java.lang.Object[] getSortVals()

clone

public java.lang.Object clone()
Clones this group.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this group. We will clone the internal arrays.