com.sun.labs.minion.retrieval
Class NegativeGroup

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

public class NegativeGroup
extends ArrayGroup

A subclass of ArrayGroup that is used to represent negative results sets. That is, a set where the contents of the set is everything except the documents contained in the array. Such a set can be generated by a <not> operator, or by combining negative and non-negative sets using certain boolean operators.

Negative sets do not have any scores associated with the documents they contain.


Nested Class Summary
protected  class NegativeGroup.NegativeDocIterator
          A class containing an iterator for the documents in this group.
 
Nested classes/interfaces inherited from class com.sun.labs.minion.retrieval.ArrayGroup
ArrayGroup.DocIterator
 
Field Summary
 
Fields inherited from class com.sun.labs.minion.retrieval.ArrayGroup
docs, logTag, part, pass, queryTerms, size, sm, width
 
Constructor Summary
protected NegativeGroup()
           
protected NegativeGroup(ArrayGroup ag)
          Constructs a negative group from the given group.
protected NegativeGroup(int[] docs, int l)
          Constructs a negative group from the given set of documents.
 
Method Summary
 ArrayGroup agIntersect(ArrayGroup ag)
          Intersects a strict group with this group.
 ArrayGroup agUnion(ArrayGroup ag)
          Union a strict group with this group.
 ArrayGroup destructiveIntersect(PostingsIterator pi)
          Intersects a postings iterator with this group, destructively.
 boolean equals(java.lang.Object o)
          Tests two negative groups for equality.
 ArrayGroup getNegative()
          Gets a negative version of this group.
 int getSize()
          Returns the size of this set.
 ArrayGroup getStrict()
          Gets a strict version of this array group, which just returns this group as an array 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)
          Intersects a scored group with this group.
 ArrayGroup.DocIterator iterator()
          Gets an iterator that will return each document in the set.
 java.lang.String toString()
           
 ArrayGroup union(NegativeGroup ag)
          Union a negative group with this group.
 ArrayGroup union(ScoredGroup ag)
          Union a scored group with this group.
 
Methods inherited from class com.sun.labs.minion.retrieval.ArrayGroup
addDoc, addPassage, addPassage, clone, destructiveIntersect, getDoc, getDocs, getPartition, getPassages, getScored, init, init, intersect, mult, normalize, removeDeleted, removeDeleted, resize, retain, setDoc, setPartition, setScoreModifier, setSize, union, union, union
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NegativeGroup

protected NegativeGroup()

NegativeGroup

protected NegativeGroup(ArrayGroup ag)
Constructs a negative group from the given group.


NegativeGroup

protected NegativeGroup(int[] docs,
                        int l)
Constructs a negative group from the given set of documents. This should be used only for testing purposes!

Method Detail

getStrict

public ArrayGroup getStrict()
Gets a strict version of this array group, which just returns this group as an array group.

Overrides:
getStrict in class ArrayGroup
Returns:
A strict group containing the same documents as this group.

getNegative

public ArrayGroup getNegative()
Gets a negative version of this group.

Overrides:
getNegative in class ArrayGroup
Returns:
A negative version of this group, which must therefore be positive. We return an instance of ArrayGroup, since there are no scores associated with the documents in a negative set.

getSize

public int getSize()
Returns the size of this set.

Overrides:
getSize in class ArrayGroup

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.

destructiveIntersect

public ArrayGroup destructiveIntersect(PostingsIterator pi)
Intersects a postings iterator with this group, destructively. This needs to switch the polarity of the group.

Overrides:
destructiveIntersect in class ArrayGroup

agUnion

public ArrayGroup agUnion(ArrayGroup ag)
Union a strict group with this group.

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

union

public ArrayGroup union(ScoredGroup ag)
Union a scored group with this group. We'll use DeMorgan's Laws to turn this into an intersection.

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.

union

public ArrayGroup union(NegativeGroup ag)
Union a negative group with this group. We'll use DeMorgan's Laws to turn this into an intersection.

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.

agIntersect

public ArrayGroup agIntersect(ArrayGroup ag)
Intersects a strict group with this group. We simply use the intersect method from StrictGroup.

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 StrictGroup is returned.

intersect

public ArrayGroup intersect(ScoredGroup ag)
Intersects a scored group with this group. We simply use the scored group intersection.

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 is returned.

intersect

public ArrayGroup intersect(NegativeGroup ag)
Intersect a negative group with this group. Uses DeMorgan's Law to transform this into a union operation.

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 NegativeGroup is returned.

iterator

public ArrayGroup.DocIterator iterator()
Gets an iterator that will return each document in the set.

Overrides:
iterator in class ArrayGroup

equals

public boolean equals(java.lang.Object o)
Tests two negative groups for equality. Two groups are equal if they contain exactly the same set of documents. A negative group can only be equal to another negative 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