simpledb.query
Class Term

java.lang.Object
  extended by simpledb.query.Term

public class Term
extends Object

A term is a comparison between two expressions.

Author:
Edward Sciore

Constructor Summary
Term(Expression lhs, Expression rhs)
          Creates a new term that compares two expressions for equality.
 
Method Summary
 boolean appliesTo(Schema sch)
          Returns true if both of the term's expressions apply to the specified schema.
 Constant equatesWithConstant(String fldname)
          Determines if this term is of the form "F=c" where F is the specified field and c is some constant.
 String equatesWithField(String fldname)
          Determines if this term is of the form "F1=F2" where F1 is the specified field and F2 is another field.
 boolean isSatisfied(Scan s)
          Returns true if both of the term's expressions evaluate to the same constant, with respect to the specified scan.
 int reductionFactor(Plan p)
          Calculates the extent to which selecting on the term reduces the number of records output by a query.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Term

public Term(Expression lhs,
            Expression rhs)
Creates a new term that compares two expressions for equality.

Parameters:
lhs - the LHS expression
rhs - the RHS expression
Method Detail

reductionFactor

public int reductionFactor(Plan p)
Calculates the extent to which selecting on the term reduces the number of records output by a query. For example if the reduction factor is 2, then the term cuts the size of the output in half.

Parameters:
p - the query's plan
Returns:
the integer reduction factor.

equatesWithConstant

public Constant equatesWithConstant(String fldname)
Determines if this term is of the form "F=c" where F is the specified field and c is some constant. If so, the method returns that constant. If not, the method returns null.

Parameters:
fldname - the name of the field
Returns:
either the constant or null

equatesWithField

public String equatesWithField(String fldname)
Determines if this term is of the form "F1=F2" where F1 is the specified field and F2 is another field. If so, the method returns the name of that field. If not, the method returns null.

Parameters:
fldname - the name of the field
Returns:
either the name of the other field, or null

appliesTo

public boolean appliesTo(Schema sch)
Returns true if both of the term's expressions apply to the specified schema.

Parameters:
sch - the schema
Returns:
true if both expressions apply to the schema

isSatisfied

public boolean isSatisfied(Scan s)
Returns true if both of the term's expressions evaluate to the same constant, with respect to the specified scan.

Parameters:
s - the scan
Returns:
true if both expressions have the same value in the scan

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.