ProjectOperator Class Reference

Sample implementation of a projection operator based on IQueryOperator. More...

#include <ProjectOperator.h>

Inherits IQueryOperator.

List of all members.

Classes

struct  ProjectionSlot

Public Member Functions

ReturnCode initialize (IQueryOperator *child, int nAttributes, const RelationAttribute attributes[])
ReturnCode openExecution ()
 Notifies the operator that query execution is about to begin.
ReturnCode closeExecution ()
 Notifies the operator that query execution has completed.
ReturnCode getNextRecord (Record *record)
 Gets the next record.
int getArity ()
 Gets the number of attributes of this operator.
void getSchema (RelationAttributeInfo attributes[])
 Gets the list of attributes of this operator.
void printSubtree (int indent)
 Prints this operator and its subtree.

Detailed Description

Sample implementation of a projection operator based on IQueryOperator.


Member Function Documentation

ReturnCode ProjectOperator::closeExecution (  )  [virtual]

Notifies the operator that query execution has completed.

This method is intended to be invoked once, after the last invocation of getNextRecord, to signal to the operator that query execution has completed (so that any necessary cleanup can be performed). The operator should call closeExecution on any children when this method is invoked, even if it does nothing else.

Implements IQueryOperator.

int ProjectOperator::getArity (  )  [virtual]

Gets the number of attributes of this operator.

Returns the number of attributes in records returned by this operator

Implements IQueryOperator.

ReturnCode ProjectOperator::getNextRecord ( Record record  )  [virtual]

Gets the next record.

Parameters:
record Record object to hold the returned record

This method is called each time the parent operator requires another record. The intention is that at the top level, QueryEngine invokes getNextRecord repeatedly on the root operator in the tree to retrieve the answers to a query. Each operator will in turn call getNextRecord on its children, while performing whatever operator-specific processing of those records is required. At the bottom of the tree, file scan or index scan operators return records from disk in their getNextRecord implementations. Returns RC_OK on success, RC_EOF if there are no more records, and other RC error codes otherwise.

The record parameter is managed by the caller, who must ensure that it is the right size returned records. (The buffer must be at least recordSize in length, where recordSize is the sum of the lengths of the attributes of this operator.)

The rationale for using a Record object, rather than simply a data buffer, is to support query plans involving updates (where the operator at the top of the execution plan needs to know the RecordID of a record matching the specified selection conditions). Unary operators, such as projection and selection, should probably preserve the RecordID of tuples passing up through them. For binary operators such as join, the returned RecordID is not meaningful and may be arbitrary.

Implements IQueryOperator.

void ProjectOperator::getSchema ( RelationAttributeInfo  attributes[]  )  [virtual]

Gets the list of attributes of this operator.

Parameters:
attributes The list of attributes to be filled in

Gets the list of attributes of this operator. The attributes array is managed by the caller and must be of length equal to getArity().

Implements IQueryOperator.

ReturnCode ProjectOperator::openExecution (  )  [virtual]

Notifies the operator that query execution is about to begin.

This method is intended to be invoked once, before the first invocation of getNextRecord, to give the operator implementation a chance to perform any necessary initialization before query execution gets underway. The operator should call openExecution on any children when this method is invoked, even if it does nothing else. Returns RC_OK on success, and other error codes on failure.

Implements IQueryOperator.

void ProjectOperator::printSubtree ( int  indent  )  [virtual]

Prints this operator and its subtree.

Parameters:
indent The level of indentation

Prints this operator and its subtree to standard output. This method is intended to support pretty-printing of query plans to the console, as discussed in the documentation for QueryEngine::select, QueryEngine::remove, and QueryEngine::update.

Implements IQueryOperator.


The documentation for this class was generated from the following files:
Generated on Sun May 16 23:18:41 2010 for DavisDB by  doxygen 1.6.3