#include <FileScanOperator.h>
Inherits IScanOperator.
Public Member Functions | |
FileScanOperator (const char *relation, int nAttributes, const RelationAttributeInfo 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. | |
ReturnCode | openScan (int nAttribute, ComparisonOp op, const TypedValue *value) |
Opens a scan with a given comparison operator and value. | |
ReturnCode | closeScan () |
Closes the scan, performing any necessary cleanup. |
Sample implementation of a record file scan operator. You are free to use the class as is, change it as you see fit, or ignore it completely.
ReturnCode FileScanOperator::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.
ReturnCode FileScanOperator::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.
ReturnCode FileScanOperator::getNextRecord | ( | Record * | record | ) | [virtual] |
Gets the next record.
record | Record object to hold the returned record |
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.
int FileScanOperator::getArity | ( | ) | [virtual] |
Gets the number of attributes of this operator.
Returns the number of attributes in records returned by this operator
Implements IQueryOperator.
void FileScanOperator::getSchema | ( | RelationAttributeInfo | attributes[] | ) | [virtual] |
Gets the list of attributes of this operator.
attributes | The list of attributes to be filled in |
Implements IQueryOperator.
void FileScanOperator::printSubtree | ( | int | indent | ) | [virtual] |
Prints this operator and its subtree.
indent | The level of indentation |
Implements IQueryOperator.
ReturnCode FileScanOperator::openScan | ( | int | nAttribute, | |
ComparisonOp | op, | |||
const TypedValue * | value | |||
) | [virtual] |
Opens a scan with a given comparison operator and value.
nAttribute | Which column is to be used in the comparison | |
op | The comparison being performed | |
value | The constant value being compared against |
Implements IScanOperator.
ReturnCode FileScanOperator::closeScan | ( | ) | [virtual] |
Closes the scan, performing any necessary cleanup.
Closes the scan, performing any necessary cleanup.
Implements IScanOperator.