ETRelationalExpr Class Reference

This abstract class defines the basic functionalities of any relational execution tree node. More...

Inherits Simba::SQLEngine::ETExpr, and Simba::DSI::IBookmarkable.

Inherited by ETBinaryExprT< ETRelationalExpr, ETRelationalExpr >, ETBinaryExprT< ETRelationalExpr, ETRelationalExpr, OperandT, AutoPtr< ETRelationalExpr >, OperandPtrT >, and ETUnaryExprT< ETRelationalExpr, ETRelationalExpr >.

List of all members.

Classes

class  Closer
 RAII class to close a relational expression on destruction. More...
class  ScopedOpen
 RAII class to ensure that a relational expression gets closed after being opened. More...

Public Member Functions

bool CanReopenAfterClose () const
 Indicates that the relational expression can be re-opened after being closed.
virtual void DisableCacheSelectivelyInSubtree ()
 Disable the caching optimization in this sub-tree.
virtual ETJoinGetAsJoin ()
 Get this ETRelationalExpr object as an ETJoin object.
virtual ETTable * GetAsTable ()
 Get the statement object as an ETTable object.
virtual ETUpdatableRelationalExpr * GetAsUpdatableRelationalExpr ()
 Get the statement object as an ETUpdatableRelationalExpr object.
virtual Simba::DSI::IColumnGetColumn (simba_uint16 in_column)
 Gets a column of the relational expression.
virtual simba_uint16 GetColumnCount ()=0
 Returns the number of columns that this relation has.
virtual Simba::DSI::IColumnsGetColumns ()
 Gets the columns of this expression.
virtual bool GetDataNeeded (simba_uint16 in_column)
 Gets the data needed status of the column as set by SetDataNeeded.
virtual bool GetRowCount (simba_uint64 &out_rowCount)=0
 Get the number of rows in the relation if it is available.
simba_double32 GetStartupCost ()
 Get the startup cost of evaluating the relational expression.
simba_double32 GetTotalCost ()
 Get the total cost of evaluating the relational expression.
virtual bool IsJoinExpr ()
 Tests whether this is a Join relational expression.
virtual bool IsOffsetSupported ()=0
 Indicate whether fetching offset is supported in the Move(...) method.
virtual bool IsRelationalExpr () const
 Determine if this ETNode is a relational expression.
virtual bool IsUpdatableRelationalExpr () const
 Tests whether this is a updatable relational expression.
bool Move (const ETMoveRequest &in_moveRequest)
 Move to the "next" record.
void NotifyCacheInvalidationListeners ()
 Notify all the cache invalidation listeners that the cache has been invalidated.
virtual void Open (Simba::DSI::DSICursorType in_cursorType)=0
 Open the node for execution.
void RegisterCacheInvalidationListener (ETCacheInvalidationListener *in_listener)
 Register a ETCacheInvalidationListener which will be notified after each successful Move() call.
virtual void Reset ()=0
 Reset the cursor position to where it initially starts.
virtual bool RetrieveData (simba_uint16 in_column, ETDataRequest &io_dataRequest)=0
 Fetch the specified column from the current row (if there is a current row) into the given ETDataRequest object.
virtual void SetCanReopenAfterClose ()
 Notify the relational expression that it can be re-opened after closing.
void SetStartupCost (simba_double32 in_startupCost)
 Set the startup evaluation cost.
void SetTotalCost (simba_double32 in_totalCost)
 Set the total evaluation cost.
virtual ~ETRelationalExpr ()
 Destructor.

Protected Member Functions

 ETRelationalExpr ()
 Default constructor.

Protected Attributes

bool m_canReopenAfterClose
simba_double32 m_startupCost
simba_double32 m_totalCost
 The cost of preparing the relational expression and retrieving all the records.

Detailed Description

This abstract class defines the basic functionalities of any relational execution tree node.

Sample relational execution tree nodes are SORT, PROJECT, TABLE.


Constructor & Destructor Documentation

virtual ~ETRelationalExpr (  )  [virtual]

Destructor.

ETRelationalExpr (  )  [protected]

Default constructor.

Protected since this is an abstract class.


Member Function Documentation

bool CanReopenAfterClose (  )  const

Indicates that the relational expression can be re-opened after being closed.

Returns:
true if the relational expression can be re-opened, otherwise false.
virtual void DisableCacheSelectivelyInSubtree (  )  [virtual]

Disable the caching optimization in this sub-tree.

This will disable caching for any ETCachedTables, however it will not disable caching for any objects which need caching to function (ETSort, ETDistinct, etc). It will also leave caching enabled for any child join nodes and leave it to them to disabled caching for their children if necessary.

This is necessary because in some cases, ETCachedTables will be created when they are not needed, as the information that they are not needed is not yet available. In these cases, disable the needless caching to avoid wasting memory/CPU cycles.

Reimplemented in ETInnerJoin.

virtual ETJoin* GetAsJoin (  )  [virtual]

Get this ETRelationalExpr object as an ETJoin object.

The default implementation here always throws an exception. ETJoin MUST override it. ETRelationalExpr::IsJoinExpr() should be used to test before calling this method.

Exceptions:
SEInvalidOperationException if this is not an ETJoin object.
Returns:
This object as an ETJoin object.

Reimplemented in ETJoin.

virtual ETTable* GetAsTable (  )  [virtual]

Get the statement object as an ETTable object.

The default implementation here always throws an exception. ETTable MUST override it.

Exceptions:
SEInvalidOperationException if this is not an ETTable object.
Returns:
This object as an ETTable object.
virtual ETUpdatableRelationalExpr* GetAsUpdatableRelationalExpr (  )  [virtual]

Get the statement object as an ETUpdatableRelationalExpr object.

The default implementation here always throws an exception. ETUpdatableRelationalExpr MUST override it.

Exceptions:
SEInvalidOperationException if this is not an ETUpdatableRelationalExpr object.
Returns:
This object as an ETUpdatableRelationalExpr object.
virtual Simba::DSI::IColumn* GetColumn ( simba_uint16  in_column  )  [virtual]

Gets a column of the relational expression.

The default implementation here always throws an exception.

Parameters:
in_column A zero-based column index.
Exceptions:
SEInvalidArgumentException if in_column is invalid.
SEInvalidOperationException if the expression does not support this method.
Returns:
A pointer to a column of the relational expression. (NOT OWN)

Reimplemented in ETInnerJoin.

virtual simba_uint16 GetColumnCount (  )  [pure virtual]

Returns the number of columns that this relation has.

Returns:
The number of columns.

Implemented in ETInnerJoin, and ETRelationalCache.

virtual Simba::DSI::IColumns* GetColumns (  )  [virtual]

Gets the columns of this expression.

The default implementation here always throws an exception.

Exceptions:
SEInvalidOperationException if the expression does not support this method.
Returns:
The columns of this expression. (NOT OWN)
virtual bool GetDataNeeded ( simba_uint16  in_column  )  [virtual]

Gets the data needed status of the column as set by SetDataNeeded.

If SetDataNeeded was not called, the value is assumed to be false.

Parameters:
in_column A zero-based column index.
Exceptions:
SEInvalidArgumentException if in_column is invalid.
Returns:
true if the column is indicated to be needed, false otherwise.

Reimplemented in ETBinaryLeftRelationalExpr< OperandT, OperandPtrT >, ETJoin, and ETUnaryRelationalExpr.

virtual bool GetRowCount ( simba_uint64 &  out_rowCount  )  [pure virtual]

Get the number of rows in the relation if it is available.

Whether the number of rows in the relation is known mainly depends on two factors,

1. Whether the input relation provides the information. 2. The actual relational expression type.

For example, A SORT relational operator should always have this information regardless whether the input relation provides the information since it has to fetch all rows on Open().

Another example, A PROJECT relational operator will know the row count only if the input relation can provide its row count.

Parameters:
out_rowCount If the rowcount is known, it will be put into here.
Returns:
Whether the rowcount is known (and thus whether out_rowCount is valid)

Implemented in ETInnerJoin, and ETRelationalCache.

simba_double32 GetStartupCost (  )  [inline]

Get the startup cost of evaluating the relational expression.

The startup cost is the cost of preparing the relational expression for data retrieval but no records have yet been retrieved.

For most queries, total cost is probably the best measure of efficiency. However, certain queries, such as EXISTS SUBQUERY, it is likely better to just consider the startup cost since not all records need to be retrieved.

Returns:
the startup cost of evaluation.
simba_double32 GetTotalCost (  )  [inline]

Get the total cost of evaluating the relational expression.

Total cost is the cost of preparing the relational expression and retrieving all the records.

Returns:
the total evaluation cost.
virtual bool IsJoinExpr (  )  [virtual]

Tests whether this is a Join relational expression.

The default implementation here always returns false.

Returns:
true if this expression is a Join, otherwise false.

Reimplemented in ETJoin.

virtual bool IsOffsetSupported (  )  [pure virtual]

Indicate whether fetching offset is supported in the Move(...) method.

This method is designed for optimization. Although SimbaEngine could support fetch offset even the underlying data store does not support it, it is more efficient if the data store supports it directly in certain situations such as the following,

  • Simple fetching everything from a table (i.e., SELECT * FROM T)
  • Fetching a subset of columns without filtering (i.e., SELECT C1,C2 FROM T)

The execution tree nodes will take this into consideration and forward the information to the DSII.

Returns:
True if supports fetch offset; false otherwise.

Implemented in ETInnerJoin, and ETRelationalCache.

virtual bool IsRelationalExpr (  )  const [virtual]

Determine if this ETNode is a relational expression.

Returns:
True if the node is a relational expression; false otherwise.

Reimplemented from ETNode.

virtual bool IsUpdatableRelationalExpr (  )  const [virtual]

Tests whether this is a updatable relational expression.

The default implementation here always returns false.

Returns:
true if this expression is a ETUpdatableRelationalExpr, false otherwise.
bool Move ( const ETMoveRequest in_moveRequest  )  [inline]

Move to the "next" record.

"next" has different meaning depending on the given cursor direction and the offset. After this method succeeds, data can be retrieved by the method RetrieveData(...).

Calls DoMove(), and then notifies cache invalidation listeners.

Parameters:
in_moveRequest The arguments container for the Move() call.
Exceptions:
SEInvalidArgumentException when direction in in_moveRequest is invalid or not supported.
Returns:
true if there is at least one record found, false otherwise.
void NotifyCacheInvalidationListeners (  ) 

Notify all the cache invalidation listeners that the cache has been invalidated.

virtual void Open ( Simba::DSI::DSICursorType  in_cursorType  )  [pure virtual]

Open the node for execution.

For different node type, the meaning of "open" might be very different.

  • For a Sort node, this means the sorting of the whole input stream.
  • For an uncorrelated sub-query in an expression, this means the execution of the sub-query. The reason is that the sub-query needs to be executed only once and it is best done at the node "open" time.
  • For most of the expression nodes, this normally means preparing the operands. (i.e., call the Open() methods on the operands.)
Parameters:
in_cursorType The cursor type.
Exceptions:
SEInvalidArgumentException when in_cursorType is invalid or not supported.
SESqlErrorException for any other reasons.

Implemented in ETInnerJoin, and ETRelationalCache.

void RegisterCacheInvalidationListener ( ETCacheInvalidationListener *  in_listener  ) 

Register a ETCacheInvalidationListener which will be notified after each successful Move() call.

Parameters:
in_listener The ETCacheInvalidationListener to register with this object. (NOT OWN)
Exceptions:
SEInvalidArgumentException If in_listener is NULL.
virtual void Reset (  )  [pure virtual]

Reset the cursor position to where it initially starts.

Depending on the cursor type, this may not applicable.

Exceptions:
SEInvalidOperationException when this operation is not supported by the current cursor.

Implements ETExpr.

Implemented in ETInnerJoin, and ETRelationalCache.

virtual bool RetrieveData ( simba_uint16  in_column,
ETDataRequest io_dataRequest 
) [pure virtual]

Fetch the specified column from the current row (if there is a current row) into the given ETDataRequest object.

See also:
ETDataRequest for the procedure that all data retrieval methods must follow. The class also documented what io_dataRequest contains after the method returns.
Parameters:
in_column A zero-based column index.
io_dataRequest Holds a buffer and other information for data retrieval.
Exceptions:
SEInvalidOperationException when the node is closed.
Returns:
true if there is more data left, false otherwise.

Implemented in ETInnerJoin, and ETRelationalCache.

virtual void SetCanReopenAfterClose (  )  [virtual]

Notify the relational expression that it can be re-opened after closing.

This node should notify any relational expression children as well.

void SetStartupCost ( simba_double32  in_startupCost  )  [inline]

Set the startup evaluation cost.

See also:
GetStartupCost() for explanation of the term "startup cost".
Parameters:
in_startupCost The startup cost of evaluation.
void SetTotalCost ( simba_double32  in_totalCost  )  [inline]

Set the total evaluation cost.

See also:
GetTotalCost() for explanation of the term "total cost".
Parameters:
in_totalCost The total evaluation cost.

Member Data Documentation

bool m_canReopenAfterClose [protected]
simba_double32 m_startupCost [protected]

The cost of preparing the relational expression for data retrieval but no records have yet been retrieved.

simba_double32 m_totalCost [protected]

The cost of preparing the relational expression and retrieving all the records.


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