Performs condition-based scans over the entries of an index. More...
#include <IndexScan.h>
Public Member Functions | |
ReturnCode | openScan (IndexHandle *indexHandle, ComparisonOp compOp, void *value) |
Opens an index scan. | |
ReturnCode | getNextEntry (RecordID *rid) |
Gets the next record matching the selection condition. | |
ReturnCode | closeScan () |
Closes the index scan. |
Performs condition-based scans over the entries of an index.
The IndexScan class is used to perform condition-based scans over the entries of a B+ tree index.
ReturnCode IndexScan::closeScan | ( | ) |
Closes the index scan.
Terminates the index scan, freeing whatever resources are associated with the scan. Returns RC_OK on succcess, and other RC codes otherwise.
ReturnCode IndexScan::getNextEntry | ( | RecordID * | rid | ) |
Gets the next record matching the selection condition.
rid | Out parameter for the id of the next matching record |
Gets the next record in the index matching the selection condition for the scan, returning its identifier in the rid out parameter. Returns RC_OK on success, RC_EOF if there are no more matching records, and other RC codes otherwise. You may assume that IndexManager clients will not close the corresponding open index while a scan is underway.
ReturnCode IndexScan::openScan | ( | IndexHandle * | indexHandle, | |
ComparisonOp | compOp, | |||
void * | value | |||
) |
Opens an index scan.
indexHandle | The handle for the index to be scanned | |
compOp | The comparison operator to be used for the scan | |
value | The value to be compared against for the scan |
Opens a condition-based scan over the entries in the open index referred to by parameter indexHandle. Once underway, the scan should produce the record ids of all records whose indexed attribute value compares in the specified way with the specified value. Parameters compOp and value are exactly as in RecordFileScan::openScan (including the possibility that compOp is ComparisonOp::NO_OP and value is a null pointer, indicating a complete scan). The only exception is that for B+ tree scans, you may choose to disallow comparison operator ComparisonOp::NE_OP (not equal). You will need to cast parameter value into the appropriate type for the attribute, as in RecordFileScan. Also, as in IndexHandle::insertEntry, if the indexed attribute is a character string of length n, then you may assume that value is exactly n bytes long (and may not be null-terminated). Returns RC_OK on success, and non-zero RC codes on failure. An open scan should eventually be closed by the client by a call to IndexScan::closeScan.