IBooleanExprHandler Class Reference

Defines the interface for passing down filter or JOIN operations to the DSII. More...

Inherited by DSIExtAbstractBooleanExprHandler.

List of all members.

Public Member Functions

virtual bool CanHandleMoreClauses ()=0
 Ask whether the handler is able to handle more Passdown() calls.
virtual bool Passdown (AEBooleanExpr *in_node)=0
 Pass down the given Boolean expression that represents either a filter or a JOIN condition.
virtual SharedPtr
< DSIExtResultSet
TakeResult ()=0
 Get the result set representing the result of applying the operations successfully.
virtual ~IBooleanExprHandler ()
 Destructor.

Protected Member Functions

 IBooleanExprHandler ()
 Constructor.

Detailed Description

Defines the interface for passing down filter or JOIN operations to the DSII.

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 break the Boolean expression into conjunctive normal form (CNF) clauses. The clauses, if there are more than one, will then be passed down one by one. After each Passdown() call, a CanHandleMoreClauses() call will be made. This gives an implementation handler class complete control over when the SQLEngine should stop attempting to pass down more clauses. The join condition of an outer join is always passed down as a whole, clauses will not be broken into CNF clauses and passed down one by one.

After attempting to pass down all clauses, a final TakeResult() call will be made regardless of the return values of the Passdown() calls. 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, but the SQLEngine is trying to pass down the expression "X > Y". The DSII could return false on the Passdown() call to indicate it cannot handle the filter, so that Simba SQLEngine will handle the expression. The DSII could still choose to return a result set representing applying the filter "X >= Y". This would be done so that the SQLEngine would be filtering fewer rows than if the DSII did no filtering, and would result in a more efficient implementation. The filtering applied by the SQLEngine ensures the results will still be correct.

The process of passing down a Boolean expression is illustrated in the following example with the compound Boolean expression:

On the first Passdown() call, the handler class will receive the whole Boolean expression. If Passdown() returns false Simba SQLEngine will break the expression into the following CNF:

Then the SQLEngine will attempt to pass down "(f1 OR f2)", 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 "f3" will not be attempted. If CanHandleMoreClauses() returns true, the engine will try to pass down the second clause "f3". Regardless of the return values of the Passdown() calls, a final TakeResult() call will be made to allow for partial filtering.

NOTE: Although the same interface is used for passing down both FILTERs and JOINs, it is very likely that a two different implementations will be needed to handle passing down FILTERs and JOINs. For the results created by passed-down joins, the function ResolveColumn() must be implemented. Before the pass down JOIN operation is finalized, all column references in the SQL statement need to be resolved so that they no longer reference the original tables. Instead, they reference this table. For example in the following query: - select T1.C1, T2.C2 from T1 JOIN T2 on T1.C1 = T2.C1

After the JOIN operation is passed down, ResolveColumn() will be called on the returned table to resolve T1.C1 and T2.C2 in the SELECT_LIST.

See also:
DSIExtResultSet::ResolveColumn().

Constructor & Destructor Documentation

virtual ~IBooleanExprHandler (  )  [inline, virtual]

Destructor.

IBooleanExprHandler (  )  [inline, protected]

Constructor.


Member Function Documentation

virtual bool CanHandleMoreClauses (  )  [pure virtual]

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 conditions to be passed down. To avoid being asked by the SQL engine whether it can 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.

Implemented in DSIExtAbstractBooleanExprHandler, and DSIExtSimpleBooleanExprHandler.

virtual bool Passdown ( AEBooleanExpr in_node  )  [pure virtual]

Pass down the given Boolean expression that represents either a filter or a JOIN condition.

This method will be called at least once before TakeResult() will be called. TakeResult() will still be called even if Passdown() returns false to allow for the DSII to partially handle filters and have the SQLEngine handle the rest.

Parameters:
in_node The root of the Boolean expression sub-tree. Cannot be NULL. (NOT OWN)
Returns:
True if the whole Boolean expression rooted at in_node is successfully passed down, false otherwise.

Implemented in DSIExtAbstractBooleanExprHandler.

virtual SharedPtr<DSIExtResultSet> TakeResult (  )  [pure virtual]

Get the result set representing the result of applying the operations successfully.

NOTE:

1) Passdown() will be called at least once before this method will be called. Note that Passdown() can return false and TakeResult() will still be called, to allow the DSII to partially filter a result and have the SQLEngine complete the rest of the filtering.

2) The result set returned can be the same table used to create this IBooleanExprHandler object (see DSIExtOperationHandlerFactory::CreateFilterHandler()). If a new result set is returned, it _MUST_ have the same ordered list of columns as the original result set. The SQLEngine will update all columns that reference the original result set to point to the new result set.

For the results created by passed-down joins, the function ResolveColumn() must be implemented. Before the pass down JOIN operation is finalized, all column references in the SQL statement need to be resolved so that they no longer reference the original tables. Instead, they reference this table.

For example in the following query:

  • select T1.C1, T2.C2 from T1 JOIN T2 on T1.C1 = T2.C1

After the JOIN operation is passed down, ResolveColumn() will be called on the returned table to resolve T1.C1 and T2.C2 in the SELECT_LIST.

See also:
DSIExtResultSet::ResolveColumn().
Returns:
The result set representing the result of applying the operations on success, NULL if no filtering has occurred.

Implemented in DSIExtAbstractBooleanExprHandler, and DSIExtSimpleBooleanExprHandler.


The documentation for this class was generated from the following file:

Generated on Wed May 17 14:21:18 2017 for SimbaEngine 10.1.3.1011 by simba