simpledb.query
Class Predicate

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

public class Predicate
extends Object

A predicate is a Boolean combination of terms.

Author:
Edward Sciore

Constructor Summary
Predicate()
          Creates an empty predicate, corresponding to "true".
Predicate(Term t)
          Creates a predicate containing a single term.
 
Method Summary
 void conjoinWith(Predicate pred)
          Modifies the predicate to be the conjunction of itself and the specified predicate.
 Constant equatesWithConstant(String fldname)
          Determines if there is a term of the form "F=c" where F is the specified field and c is some constant.
 String equatesWithField(String fldname)
          Determines if there is a term of the form "F1=F2" where F1 is the specified field and F2 is another field.
 boolean isSatisfied(Scan s)
          Returns true if the predicate evaluates to true with respect to the specified scan.
 Predicate joinPred(Schema sch1, Schema sch2)
          Returns the subpredicate consisting of terms that apply to the union of the two specified schemas, but not to either schema separately.
 int reductionFactor(Plan p)
          Calculates the extent to which selecting on the predicate reduces the number of records output by a query.
 Predicate selectPred(Schema sch)
          Returns the subpredicate that applies to the specified schema.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Predicate

public Predicate()
Creates an empty predicate, corresponding to "true".


Predicate

public Predicate(Term t)
Creates a predicate containing a single term.

Parameters:
t - the term
Method Detail

conjoinWith

public void conjoinWith(Predicate pred)
Modifies the predicate to be the conjunction of itself and the specified predicate.

Parameters:
pred - the other predicate

isSatisfied

public boolean isSatisfied(Scan s)
Returns true if the predicate evaluates to true with respect to the specified scan.

Parameters:
s - the scan
Returns:
true if the predicate is true in the scan

reductionFactor

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

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

selectPred

public Predicate selectPred(Schema sch)
Returns the subpredicate that applies to the specified schema.

Parameters:
sch - the schema
Returns:
the subpredicate applying to the schema

joinPred

public Predicate joinPred(Schema sch1,
                          Schema sch2)
Returns the subpredicate consisting of terms that apply to the union of the two specified schemas, but not to either schema separately.

Parameters:
sch1 - the first schema
sch2 - the second schema
Returns:
the subpredicate whose terms apply to the union of the two schemas but not either schema separately.

equatesWithConstant

public Constant equatesWithConstant(String fldname)
Determines if there is a term 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 there is a term 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:
the name of the other field, or null

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.