com.sun.labs.minion.retrieval
Class ScoredGroup

java.lang.Object
  extended by com.sun.labs.minion.retrieval.ArrayGroup
      extended by com.sun.labs.minion.retrieval.ScoredGroup
All Implemented Interfaces:
java.lang.Cloneable

public class ScoredGroup
extends ArrayGroup

A scored array group is one for which the documents have scores associated with them. When combined with another group via one of the combination operators, the scores for documents in both groups will be combined according to the dictates of the operator.


Nested Class Summary
 class ScoredGroup.ScoredDocIterator
          A class for an iterator for this set.
 
Nested classes/interfaces inherited from class com.sun.labs.minion.retrieval.ArrayGroup
ArrayGroup.DocIterator
 
Field Summary
protected  boolean normalized
          A flag indicating whether normalization has been performed on this group or not.
protected  float[] scores
          The scores for the documents in the set.
protected  float sqw
          The sum of the squared query weights for this group.
protected  float[] weights
          The weights to be applied (eventually) to the scores.
 
Fields inherited from class com.sun.labs.minion.retrieval.ArrayGroup
docs, logTag, part, pass, queryTerms, size, sm, width
 
Constructor Summary
protected ScoredGroup(ArrayGroup ag)
          Creates a scored group from the given group.
  ScoredGroup(DiskPartition part, double[] dist)
          Creates a scored group from a set of euclidean distances between documents.
  ScoredGroup(DiskPartition part, float[] scores)
           
  ScoredGroup(DiskPartition part, int[] docs, float[] scores, int l)
          Creates a scored group from the given arrays.
  ScoredGroup(DiskPartition part, int[] docs, float[] scores, int l, float sqw)
          Creates a scored group from the given arrays.
  ScoredGroup(int n)
           
  ScoredGroup(int[] docs, float[] scores, int l)
          Creates a scored group from the given arrays.
  ScoredGroup(PostingsIterator pi)
          Creates an array group from the given postings iterator.
  ScoredGroup(PostingsIterator pi, float qw)
          Creates an array group from the given postings iterator.
 
Method Summary
 void addDoc(int docID, float score)
          Adds a document to the group.
 ArrayGroup agIntersect(ArrayGroup ag)
          Intersect a strict boolean group with this group.
protected  ArrayGroup agUnion(ArrayGroup ag)
          Unions a statically type array group with this group.
 java.lang.Object clone()
          Clones this group.
 ArrayGroup destructiveIntersect(PostingsIterator pi)
          Intersects a postings iterator with this group, destructively.
 ArrayGroup destructiveMult(float m)
           
 ScoredGroup discardBelow(float score)
          Discards any entries in this scored group that are a score less than the value supplied
 boolean equals(java.lang.Object o)
          Tests two scored groups for equality.
 float getScore(int i)
          Get the score at a particular index
 ScoredGroup getScored()
          Gets a scored group from this group, which just returns this group.
 ArrayGroup intersect(NegativeGroup ag)
          Intersect a negative group with this group.
 ArrayGroup intersect(QueryTerm t)
          Intersects the documents generated by the term with the ones in this group.
 ArrayGroup intersect(ScoredGroup ag)
          Intersect a scored group with this group.
 ArrayGroup.DocIterator iterator()
          Gets an iterator for the documents in this group.
 ArrayGroup mult(float m)
          Applies a multiplier to an array group, returning a new group.
 ArrayGroup normalize()
          Normalizes the scores by the document length.
 ArrayGroup normalize(int field)
          Normalizes the scores by the document length.
 void removeDeleted(ReadableBuffer del)
          Removes deleted documents from the results set, modifying the set in the process.
 void retain(int[] ids)
          Retain only the documents with the given ids
 void setNormalized()
           
 void setScore(int i, float score)
          Sets the score at a particular index
 ScoredGroup sort()
          Sorts this group by score, returning a sorted version.
 ScoredGroup sort(boolean destructive)
          Sorts this group by score, returning a sorted version.
 java.lang.String toString()
           
 java.lang.String toString(int t)
           
 ArrayGroup union(ScoredGroup ag)
          Union a scored group with this group.
 
Methods inherited from class com.sun.labs.minion.retrieval.ArrayGroup
addDoc, addPassage, addPassage, destructiveIntersect, getDoc, getDocs, getNegative, getPartition, getPassages, getSize, getStrict, init, init, intersect, removeDeleted, resize, setDoc, setPartition, setScoreModifier, setSize, union, union, union, union
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scores

protected float[] scores
The scores for the documents in the set.


weights

protected float[] weights
The weights to be applied (eventually) to the scores.


sqw

protected float sqw
The sum of the squared query weights for this group.


normalized

protected boolean normalized
A flag indicating whether normalization has been performed on this group or not.

Constructor Detail

ScoredGroup

public ScoredGroup(int n)

ScoredGroup

public ScoredGroup(DiskPartition part,
                   float[] scores)

ScoredGroup

protected ScoredGroup(ArrayGroup ag)
Creates a scored group from the given group.


ScoredGroup

public ScoredGroup(PostingsIterator pi)
Creates an array group from the given postings iterator.


ScoredGroup

public ScoredGroup(PostingsIterator pi,
                   float qw)
Creates an array group from the given postings iterator. This constructor is implicitly performing a dot product of the query term and the documents in the iterator.

Parameters:
pi - the postings iterator from which we will get the documents and scores for the group.
qw - the weight associated with the query term that produced these postings.

ScoredGroup

public ScoredGroup(int[] docs,
                   float[] scores,
                   int l)
Creates a scored group from the given arrays. This should be used only for testing purposes!


ScoredGroup

public ScoredGroup(DiskPartition part,
                   int[] docs,
                   float[] scores,
                   int l)
Creates a scored group from the given arrays. This should be used only for testing purposes!


ScoredGroup

public ScoredGroup(DiskPartition part,
                   int[] docs,
                   float[] scores,
                   int l,
                   float sqw)
Creates a scored group from the given arrays. This should be used only for testing purposes!


ScoredGroup

public ScoredGroup(DiskPartition part,
                   double[] dist)
Creates a scored group from a set of euclidean distances between documents. The score for a document is the distance, which means that you will need to sort by increasing score to get the documents in the order that you would like!

We will leave it up to the application to normalize such scores.

Parameters:
part - the partition from which the distances were calculated.
dist - an array of doubles containing the distances between documents.
Method Detail

getScored

public ScoredGroup getScored()
Gets a scored group from this group, which just returns this group.

Overrides:
getScored in class ArrayGroup
Returns:
A scored group containing the same documents as this group. If this group is a scored group, the documents in the new group will have the same scores, otherwise all of the scores will be 1.

getScore

public float getScore(int i)
Get the score at a particular index


addDoc

public void addDoc(int docID,
                   float score)
Adds a document to the group.


setScore

public void setScore(int i,
                     float score)
Sets the score at a particular index


intersect

public ArrayGroup intersect(QueryTerm t)
Intersects the documents generated by the term with the ones in this group.

Overrides:
intersect in class ArrayGroup
Parameters:
t - The term to intersect with the current set.
Returns:
The result of intersecting the given term with this set. The static type of the result is determined by a combination of the types of the groups being combined and the current query status.

removeDeleted

public void removeDeleted(ReadableBuffer del)
Removes deleted documents from the results set, modifying the set in the process.

Overrides:
removeDeleted in class ArrayGroup

retain

public void retain(int[] ids)
Description copied from class: ArrayGroup
Retain only the documents with the given ids

Overrides:
retain in class ArrayGroup
Parameters:
ids - document ids to keep

normalize

public ArrayGroup normalize()
Normalizes the scores by the document length.

Overrides:
normalize in class ArrayGroup

normalize

public ArrayGroup normalize(int field)
Normalizes the scores by the document length.

Parameters:
field - the ID of a vectored field whose length we should use. If this is -1, then the length computed across all vectored fields is used. If this is 0, then the length for the data not in any explicit field is used. If this is not 0, then the length of that field is used. Note if this ID is not for a vectored field, then a default length of 1 will be used!
Returns:
this group with normalized scores

setNormalized

public void setNormalized()

destructiveIntersect

public ArrayGroup destructiveIntersect(PostingsIterator pi)
Intersects a postings iterator with this group, destructively.

Overrides:
destructiveIntersect in class ArrayGroup

discardBelow

public ScoredGroup discardBelow(float score)
Discards any entries in this scored group that are a score less than the value supplied

Parameters:
score - the score below which to discard values
Returns:
this group

agUnion

protected ArrayGroup agUnion(ArrayGroup ag)
Unions a statically type array group with this group. We'll use the method from ArrayGroup to do this.

Overrides:
agUnion in class ArrayGroup

union

public ArrayGroup union(ScoredGroup ag)
Union a scored group with this group. The current group is modified and returned.

Overrides:
union in class ArrayGroup
Parameters:
ag - The scored group to union with this group.
Returns:
The result of unioning the given group with this group. An instance of ScoredGroup is returned.

agIntersect

public ArrayGroup agIntersect(ArrayGroup ag)
Intersect a strict boolean group with this group.

Overrides:
agIntersect in class ArrayGroup
Parameters:
ag - The scored group to intersect with this group.
Returns:
The result of intersecting the given group with this group. An instance of ScoredGroup is returned.

intersect

public ArrayGroup intersect(ScoredGroup ag)
Intersect a scored group with this group.

Overrides:
intersect in class ArrayGroup
Parameters:
ag - The scored group to intersect with this group.
Returns:
The result of intersecting the given group with this group. An instance of ScoredGroup will be returned.

intersect

public ArrayGroup intersect(NegativeGroup ag)
Intersect a negative group with this group. The current group is modified and returned.

Overrides:
intersect in class ArrayGroup
Parameters:
ag - The scored group to intersect with this group.
Returns:
The result of intersecting the given group with this group.

mult

public ArrayGroup mult(float m)
Applies a multiplier to an array group, returning a new group. This will only affect scored groups, but a query may apply a multiplier to any group.

Overrides:
mult in class ArrayGroup
Parameters:
m - The multiplier to apply.
Returns:
A group where the multiplier has been applied. The current group is not affected.

destructiveMult

public ArrayGroup destructiveMult(float m)

iterator

public ArrayGroup.DocIterator iterator()
Gets an iterator for the documents in this group.

Overrides:
iterator in class ArrayGroup

sort

public ScoredGroup sort()
Sorts this group by score, returning a sorted version. Note that the returned group will be useless for any further retrieval operations.


sort

public ScoredGroup sort(boolean destructive)
Sorts this group by score, returning a sorted version. Note that the returned group will be useless for any further retrieval operations.

Parameters:
destructive - if true, this group is modified

clone

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

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

equals

public boolean equals(java.lang.Object o)
Tests two scored groups for equality. Two scored groups are equal if they contain exactly the same set of documents. A scored group can only be equal to another scored group.

Overrides:
equals in class ArrayGroup
Returns:
true if the groups contain the same documents, false otherwise.

toString

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

toString

public java.lang.String toString(int t)