com.sun.labs.minion.retrieval
Class FieldTerm

java.lang.Object
  extended by com.sun.labs.minion.retrieval.QueryElement
      extended by com.sun.labs.minion.retrieval.QueryTerm
          extended by com.sun.labs.minion.retrieval.FieldTerm
All Implemented Interfaces:
java.lang.Comparable

public class FieldTerm
extends QueryTerm

A class to hold a term generated by a single parametric field operator. It should be used in cases where there is a single operation on a single field. When there are overlapping operations on a single field (e.g., num >= 1 <and> num < 25), the RangeFieldTerm should be used.


Field Summary
protected static long dayMilliSeconds
           
protected  CDateParser dp
          A date parser for date fields.
protected  boolean includeLower
          Lower bound is inclusive?
protected  boolean includeUpper
          Upper bound is inclusive?
protected  DictionaryIterator iter
          An iterator that will produce terms from the dictionary associated with this saved field.
protected static java.lang.String logTag
           
protected  java.lang.Object lowerBound
          For range queries, this is the lower bound on the range.
protected  java.lang.String name
          The name of the field that is begin operated on.
protected  Relation.Operator op
          The parametric operator, as defined in the relation class.
protected  PostingsIterator pi
          The postings for a a single term pulled from the dictionary associated with this saved field.
protected  boolean selectRange
          This should be true if this FieldTerm was constructed with range data.
protected  java.lang.Object upperBound
          For range queries, this is the upper bound on the range.
protected  java.lang.String val
          The value given in the query.
 
Fields inherited from class com.sun.labs.minion.retrieval.QueryTerm
doExpand, doMorph, doStem, doWild, loadPositions, matchCase
 
Fields inherited from class com.sun.labs.minion.retrieval.QueryElement
estSize, fieldMultipliers, inOrder, keepPositions, order, part, qc, qs, searchFieldNames, searchFields, strictEval, wc, wf
 
Constructor Summary
FieldTerm(java.lang.String name, java.lang.Object lowerBound, boolean includeLower, java.lang.Object upperBound, boolean includeUpper)
          Construct a field term with a specific range of valid values.
FieldTerm(java.lang.String name, Relation.Operator op, java.lang.String val)
          Creates a field term.
 
Method Summary
protected  int calculateEstimatedSize()
          Estimates the size of the results set for the given term.
 ArrayGroup eval(ArrayGroup ag)
          Evaluates the term in the current partition.
 java.lang.String getName()
           
 Relation.Operator getOp()
           
 java.util.List getQueryTerms(java.util.Comparator c)
          Returns a list of all the regular terms in this query in the order that they appeared in the query.
 java.lang.Object getValue()
          Gets the value of this field term, if it is not a range operation.
protected static boolean isDayResolution(java.util.Date d)
          Checks whether a given date has a day-level resolution.
 void setPartition(DiskPartition part)
          Sets the current partition, and makes sure that we have valid search field and multiplier arrays for this partition.
 java.lang.String toString(java.lang.String prefix)
           
 
Methods inherited from class com.sun.labs.minion.retrieval.QueryTerm
setDoExpand, setDoMorph, setDoStem, setDoWild, setLoadPositions, setMatchCase, setQueryConfig
 
Methods inherited from class com.sun.labs.minion.retrieval.QueryElement
addSearchFieldName, compareTo, dump, estimateSize, getInOrder, getOrder, getQueryStats, getQueryTerms, getSearchFieldNames, setInOrder, setOrder, setQueryStats, setSearchFields, setWeightingComponents, setWeightingFunction, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of the field that is begin operated on.


op

protected Relation.Operator op
The parametric operator, as defined in the relation class.


val

protected java.lang.String val
The value given in the query.


dp

protected CDateParser dp
A date parser for date fields.


lowerBound

protected java.lang.Object lowerBound
For range queries, this is the lower bound on the range.


includeLower

protected boolean includeLower
Lower bound is inclusive?


upperBound

protected java.lang.Object upperBound
For range queries, this is the upper bound on the range.


includeUpper

protected boolean includeUpper
Upper bound is inclusive?


iter

protected DictionaryIterator iter
An iterator that will produce terms from the dictionary associated with this saved field. This will be used when a range of terms is requested (e.g., for a <= operator);


pi

protected PostingsIterator pi
The postings for a a single term pulled from the dictionary associated with this saved field. This will be used when a single term is requested (e.g., for an = operator).


selectRange

protected boolean selectRange
This should be true if this FieldTerm was constructed with range data.


logTag

protected static java.lang.String logTag

dayMilliSeconds

protected static long dayMilliSeconds
Constructor Detail

FieldTerm

public FieldTerm(java.lang.String name,
                 Relation.Operator op,
                 java.lang.String val)
Creates a field term.

Parameters:
name - The name of the field that we're operating on.
op - The operator that we're using.
val - The value to compare against, given in the query.

FieldTerm

public FieldTerm(java.lang.String name,
                 java.lang.Object lowerBound,
                 boolean includeLower,
                 java.lang.Object upperBound,
                 boolean includeUpper)
Construct a field term with a specific range of valid values. This constructor handles queries in the form of (a < x < b). All parameters must be valid and the operation is assumed to be RANGE.

Parameters:
name - the name of the field to operate on
lowerBound - the lower bound on the range
includeLower - true if the lower bound is inclusive
upperBound - the upper bound on the range
includeUpper - true if the upper bound is inclusive
Method Detail

getName

public java.lang.String getName()

getOp

public Relation.Operator getOp()

getValue

public java.lang.Object getValue()
Gets the value of this field term, if it is not a range operation. Otherwise, returns null.

Returns:
the value

setPartition

public void setPartition(DiskPartition part)
Description copied from class: QueryElement
Sets the current partition, and makes sure that we have valid search field and multiplier arrays for this partition. This should be propagated to any components of the query element!

Overrides:
setPartition in class QueryElement

isDayResolution

protected static boolean isDayResolution(java.util.Date d)
Checks whether a given date has a day-level resolution. Checks if hour, minute, second are all 0.


calculateEstimatedSize

protected int calculateEstimatedSize()
Estimates the size of the results set for the given term.

Specified by:
calculateEstimatedSize in class QueryElement
Returns:
The estimated size of the results set for this element. This is meant to be an as-tight-as-possible estimate of the results set size. It is acceptable to overestimate, but not to underestimate the size of the result set.

eval

public ArrayGroup eval(ArrayGroup ag)
Evaluates the term in the current partition.

Specified by:
eval in class QueryTerm
Parameters:
ag - An array group that we can use to limit the evaluation of the term. If this group is null a new group will be returned. If this group is non-null, then the elements in the group will be used to restrict the documents that we return from the term.
Returns:
A new ArrayGroup containing the results of evaluating the term against the given group. We will return an instance of StrictGroup, since there are no weights associated with the values.

getQueryTerms

public java.util.List getQueryTerms(java.util.Comparator c)
Description copied from class: QueryElement
Returns a list of all the regular terms in this query in the order that they appeared in the query. Field Terms and terms within a not or a hide expression will not be returned.

Specified by:
getQueryTerms in class QueryElement
Parameters:
c - A comparator used to order the terms.

toString

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