com.simba.dsi.ext
Class AbstractBooleanExprHandler

java.lang.Object
  extended by com.simba.dsi.ext.AbstractBooleanExprHandler
Direct Known Subclasses:
SimpleBooleanExprHandler

public abstract class AbstractBooleanExprHandler
extends java.lang.Object

An abstract class that facilitates passing down filter and join operations.

Simba SQLEngine will always attempt to pass down the whole Boolean expression first whether the Boolean expression represents a filter or a join condition.

If passing down the whole Boolean expression succeeds (Passdown() returns true), the engine will make a TakeResult() call to get the result set representing the result of applying the passed down operations.

If passing down the whole Boolean expression fails (Passdown() returns false) and the Boolean expression is not a join condition for an outer JOIN, the engine will convert the Boolean expression into conjunctive normal form (CNF). The clauses will then be passed down one by one if the Boolean expression in CNF has more than one clause. After each Passdown() call, a CanHandleMoreClauses() call will be made. This gives an implementation handler class the complete control over when the SQLEngine should stop attempting to pass down more clauses. In other words, the join condition of an outer join is always passed down as a whole. No passing down once clause at a time will be attempted.

After attempting to pass down all clauses, a final TakeResult() call will be made regardless the status values returned by each Passdown() call. This design allows a "partial" Boolean expression to be handled transparently. For example, if the DSII is only able to handle the Boolean expression "X >= Y" as a filter. If the engine is trying to pass down the expression "X > Y", the DSII could return false on Passdown() call so that Simba SQLEngine will handle the expression. The DSII could still choose to return a result set representing applying the filter "X >= Y". In this arrangement, very likely less rows will be returned to the SQLEngine to apply the filter "X > Y". The final result set returned by the SQLEngine will still be correct.

The process of passing down a Boolean expression is illustrated in the following example. For example, for the following compound Boolean expression,

   (f1 AND f2) OR f3
 
On the first Passdown() call, the handler class will receive the whole Boolean expression. If the call returns false. Simba SQLEngine will convert the expression into the following CNF.
   (f1 OR f3) AND (f2 OR f3)
 

Then the SQLEngine will attempt to pass down "(f1 OR f3)", the first clause of the Boolean expression in CNF. Once Passdown() returns (regardless of its return value), the engine will make a CanHandleMoreClauses() call. If CanHandleMoreClauses() returns false, the engine will not make any more Passdown() calls. That is, passing down the second clause "(f2 OR f3)" will not be attempted. If CanHandleMoreClauses() returns true, the engine will try to pass down the second clause "(f2 OR f3)". If there is at least one Passdown() call that returns true, a final TakeResult() call will be made.

NOTE:
Although the same interface is used for passing down both FILTERs and JOINs, it is very likely that a customer will need different implementations to handle passing down FILTERs and JOINs.


Constructor Summary
AbstractBooleanExprHandler()
           
 
Method Summary
abstract  boolean canHandleMoreClauses()
          Ask whether the handler is able to handle more Passdown() calls.
 boolean passdownAnd(AEAnd node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownComparison(AEComparison node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownExistsPredicate(AEExistsPredicate 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 passdownLikePredicate(AELikePredicate 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.
 boolean passdownOr(AEOr node)
          Pass down the given Boolean expression as a filter or join condition.
 boolean passdownQuantifiedComparison(AEQuantifiedComparison node)
          Pass down the given Boolean expression as a filter or join condition.
abstract  DSIExtResultSet takeResult()
          Retrieve the result set representing the result of applying the Boolean expression as a filter or join condition successfully.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBooleanExprHandler

public AbstractBooleanExprHandler()
Method Detail

canHandleMoreClauses

public abstract boolean canHandleMoreClauses()
Ask whether the handler is able to handle more Passdown() calls.

After each Passdown() call, this method is called. It allows the handler to stop the Passdown process if the handler is able to make the decision upon observing certain Boolean expressions. Essentially, it gives the customer handler the ability to "short circuit" the pass down process.

For example, if a handler is used for passing down a JOIN operation and once the JOIN is handled, it will not allow any more JOIN condition to be passed down. To avoid being asked by the SQL engine whether it could handle more clauses, the implementation for the JOIN handler could simply returns false after a JOIN condition is handled.

Returns:
true if the handler is able to handle more conditions, false otherwise.

passdownAnd

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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 successfully passed down, false otherwise.

passdownComparison

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

passdownExistsPredicate

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

passdownInPredicate

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

passdownLikePredicate

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

passdownOr

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

passdownQuantifiedComparison

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

This default implementation always return false. That is, the Boolean expression is not supported. A sub-class wishing to support this Boolean expression should override this method.

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.

takeResult

public abstract DSIExtResultSet takeResult()
Retrieve the result set representing the result of applying the Boolean expression as a filter or join condition successfully.

NOTE:

  1. passdown(...) must be successfully called at least once before this method can be invoked, otherwise this method should throw an exception.
  2. The result set returned can be the same result set used to create this IFilterHandler object (see OperationHandlerFactory.createFilterHandler(DSIExtResultSet)). If a new result set is returned, it _MUST_ has the same ordered list of columns as the original result set. SimbaEngine will update all columns that reference the original result set to point to the new result set.

Returns:
The result set representing the result, null otherwise.


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