com.simba.dsi.ext
Class SimpleBooleanExprHandler

java.lang.Object
  extended by com.simba.dsi.ext.AbstractBooleanExprHandler
      extended by com.simba.dsi.ext.SimpleBooleanExprHandler

public abstract class SimpleBooleanExprHandler
extends AbstractBooleanExprHandler

Define an abstract class that simplifies the process of passing down a list of "simple" Boolean expressions.

The following is the list of "simple" Boolean expressions,

An implementation wishing to support a subset of the Boolean expressions listed above should extends this class directly. It should only need to provide implementation for the abstract methods only. If more complicated Boolean expressions need to be supported, it should consider extending AbstractBooleanExprHandler directly.


Nested Class Summary
protected static class SimpleBooleanExprHandler.LiteralValue
          A class which encapsulates in AELiteral node and a boolean indicating if the literal has been negated in the query.
 
Constructor Summary
SimpleBooleanExprHandler()
           
 
Method Summary
 boolean passdownComparison(AEComparison node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownInPredicate(AEInPredicate node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownNot(AENot node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownNullPredicate(AENullPredicate node)
          Pass down the given Boolean expression as a filter or join condition.
protected abstract  boolean passdownSimpleComparison(ColumnRef leftExpr, ColumnRef rightExpr, ComparisonType compOp)
          Pass down the given Boolean expression as a filter or join condition.
protected abstract  boolean passdownSimpleComparison(ColumnRef leftExpr, SimpleBooleanExprHandler.LiteralValue rightExpr, ComparisonType compOp)
          Pass down the given Boolean expression as a filter or join condition.
protected abstract  boolean passdownSimpleInPredicate(ColumnRef column, java.util.ArrayList<SimpleBooleanExprHandler.LiteralValue> literals)
          Pass down the given Boolean expression as a filter or join condition.
protected abstract  boolean passdownSimpleNullPredicate(ColumnRef column, boolean isNull)
          Pass down the given Boolean expression as a filter or join condition.
 
Methods inherited from class com.simba.dsi.ext.AbstractBooleanExprHandler
canHandleMoreClauses, passdownAnd, passdownExistsPredicate, passdownLikePredicate, passdownOr, passdownQuantifiedComparison, takeResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBooleanExprHandler

public SimpleBooleanExprHandler()
Method Detail

passdownComparison

public boolean passdownComparison(AEComparison node)
Pass down the given Boolean expression as a filter or join condition.

The implementation provides support only for the following forms of comparisons,

In other words, no expressions other than column references and literals values are supported.

A sub-class only needs to provide implementation for the protected method passdownSimpleComparison(). Also, the sub-class does not need to deal with comparisons in the form of <literal> <compOp> <column_reference> since this method translates it into an equivalent form of <column_reference> <reversed_compOp> <literal>.

Overrides:
passdownComparison in class AbstractBooleanExprHandler
Parameters:
node - The root of the Boolean expression sub-tree. Cannot be null.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.
See Also:
AbstractBooleanExprHandler.passdownComparison(AEComparison)

passdownInPredicate

public boolean passdownInPredicate(AEInPredicate node)
Pass down the given Boolean expression as a filter or join condition.

The implementation provides support only for the following form of <in predicate>,

 <column_reference> IN (<literal>, <literal>, ...)
 
That is, the only allowed expression for the first operand is a column reference and the only allowed expression for the second operand is a list of literal values.

Internally, this method calls passdownSimpleInPredicate() to support the operation. A sub-class should provide implementation for passdownSimpleInPredicate() if the only form of <in predicate> wishing to support is as documented here. Otherwise, override this method.

Overrides:
passdownInPredicate in class AbstractBooleanExprHandler
Parameters:
node - The root of the Boolean expression sub-tree. Cannot be null.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownNot

public boolean passdownNot(AENot node)
Pass down the given Boolean expression as a filter or join condition.

The implementation provides support only for the following form of <not>,

 <column_reference> IS [NOT] NULL.
 
In other words, no value expression other than a null predicate with a column reference is supported.

A sub-class only needs to provide implementation for the protected method passdownSimpleNullPredicate().

Overrides:
passdownNot in class AbstractBooleanExprHandler
Parameters:
node - The root of the Boolean expression sub-tree. Cannot be null.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownNullPredicate

public boolean passdownNullPredicate(AENullPredicate node)
Pass down the given Boolean expression as a filter or join condition.

The implementation provides support only for the following form of <null predicate>,

 <column_reference> IS NULL.
 
In other words, no value expression other than a column reference is supported.

A sub-class only needs to provide implementation for the protected method passdownSimpleNullPredicate().

Overrides:
passdownNullPredicate in class AbstractBooleanExprHandler
Parameters:
node - The root of the Boolean expression sub-tree. Cannot be null.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownSimpleComparison

protected abstract boolean passdownSimpleComparison(ColumnRef leftExpr,
                                                    SimpleBooleanExprHandler.LiteralValue rightExpr,
                                                    ComparisonType compOp)
Pass down the given Boolean expression as a filter or join condition.

The Boolean expression is a comparison of the following form,

 <leftExpr> <compOp> <rightExpr>
 
This method is called by passdownComparison(AEComparison) in one of two situations,
  1. The left operand is a column reference and right operand is a literal value.
  2. The right operand is a column reference and left operand is a literal value and comparison operator is reversed before calling this method.

Parameters:
leftExpr - Left side expression.
rightExpr - Right side expression.
compOp - The comparison operator to apply to the expressions.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownSimpleComparison

protected abstract boolean passdownSimpleComparison(ColumnRef leftExpr,
                                                    ColumnRef rightExpr,
                                                    ComparisonType compOp)
Pass down the given Boolean expression as a filter or join condition.

The Boolean expression is a comparison of the following form,

 <leftExpr> <compOp> <rightExpr>
 
This method is called by passdownComparison(AEComparison) when both operands are column references.

Parameters:
leftExpr - Left side expression.
rightExpr - Right side expression.
compOp - The comparison operator to apply to the expressions.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownSimpleInPredicate

protected abstract boolean passdownSimpleInPredicate(ColumnRef column,
                                                     java.util.ArrayList<SimpleBooleanExprHandler.LiteralValue> literals)
Pass down the given Boolean expression as a filter or join condition.

It should only support <in predicate> of this form,

 <column> IN (literals)
 
This method is called by passdownInPredicate(AEInPredicate) when the list of expressions are all literal values.

If a sub-class only wishes to support <in predicate> of the form seen here, it should only need to provide implementation for this method only. Otherwise, it needs to override passdownInPredicate(AEInPredicate) and provide a default implementation (simply returns false) for this method.

Parameters:
column - The left operand of the predicate. Cannot be NULL.
literals - A list of literal values.
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.

passdownSimpleNullPredicate

protected abstract boolean passdownSimpleNullPredicate(ColumnRef column,
                                                       boolean isNull)
Pass down the given Boolean expression as a filter or join condition.

This method is called by passdownNullPredicate(AENullPredicate) or passdownNot(AENot) to support the <null predicate> of this form,

 <column> IS [NOT] NULL.
 

This method is called by passdownNullPredicate(AENullPredicate) for the "IS NULL" case when the expression is a column reference. This method is called by passdownNot(AENot) for the "IS NOT NULL" case when the expression is a column reference.

Parameters:
column - The column expression.
isNull - true for "IS NULL", false for "IS NOT NULL".
Returns:
true if the Boolean expression as a filter or join condition is successfully passed down, false otherwise.


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.