Inherited by append_file_i.
Inheritance diagram for scan_file_i:
To iterate over the records in a file, construct an instance of this class, and use its next, next_page and eof methods to located the records in the file. The methods next and next_page return a pin_i, which lets you manipulate the record (pin it in the buffer pool while you use it). It is unwise to delete or insert records while you have a scan open on the file (in the same transaction).
stid_t fid(1,7); scan_file_i scan(fid); pin_i* cursor(NULL); bool eof(false); do { w_rc_t rc = scan.next(cursor, 0, eof); if(rc.is_error()) { // handle error ... } if(eof) break; // handle record ... const char *body = cursor->body(); ... } while (1);
Definition at line 437 of file scan.h.
Public Member Functions | |
NORET | scan_file_i (const stid_t &stid, const rid_t &start, concurrency_t cc=t_cc_file, bool prefetch=false, lock_mode_t ignored=SH) |
Construct an iterator over the given store (file). | |
NORET | scan_file_i (const stid_t &stid, concurrency_t cc=t_cc_file, bool prefetch=false, lock_mode_t ignored=SH) |
Construct an iterator over the given store (file). | |
void | cursor (pin_i *&pin_ptr, bool &eof) |
Return the pin_i that represents the scan state. | |
rc_t | next (pin_i *&pin_ptr, smsize_t start_offset, bool &eof) |
Advance to the next record of the file. | |
rc_t | next_page (pin_i *&pin_ptr, smsize_t start_offset, bool &eof) |
Advance to the first record on the next page in the file. | |
void | finish () |
Free resources acquired by this iterator. Useful if you are finished with the scan but not ready to delete it. | |
bool | eof () |
End of file was reached. Cursor is not usable. | |
const rc_t & | error_code () const |
Error code returned from last method call. | |
tid_t | xid () const |
ID of the transaction that created this iterator. | |
Public Attributes | |
stid_t | stid |
rid_t | curr_rid |
Protected Attributes | |
tid_t | tid |
bool | _eof |
w_rc_t | _error_occurred |
pin_i | _cursor |
lpid_t | _next_pid |
concurrency_t | _cc |
lock_mode_t | _page_lock_mode |
lock_mode_t | _rec_lock_mode |
NORET scan_file_i::scan_file_i | ( | const stid_t & | stid, | |
const rid_t & | start, | |||
concurrency_t | cc = t_cc_file , |
|||
bool | prefetch = false , |
|||
lock_mode_t | ignored = SH | |||
) |
Construct an iterator over the given store (file).
[in] | stid | ID of the file over which to iterate. |
[in] | start | ID of the first record of interest, can be used to start a scan in the middle of the file. |
[in] | cc | Locking granularity to be used. See discussion for other constructor. |
[in] | prefetch | If true, a background thread will pre-fetch pages in support of this scan. For this to work the server option sm_prefetch must be enabled. |
[in] | ignored | not used |
NORET scan_file_i::scan_file_i | ( | const stid_t & | stid, | |
concurrency_t | cc = t_cc_file , |
|||
bool | prefetch = false , |
|||
lock_mode_t | ignored = SH | |||
) |
Construct an iterator over the given store (file).
[in] | stid | ID of the file over which to iterate. |
[in] | cc | Locking granularity to be used. The following are permissible, and their implied store, page and record lock modes are given:
|
[in] | prefetch | If true, a background thread will pre-fetch pages in support of this scan. For this to work the server option sm_prefetch must be enabled. |
[in] | ignored | not used |
void scan_file_i::cursor | ( | pin_i *& | pin_ptr, | |
bool & | eof | |||
) | [inline] |
Advance to the next record of the file.
[out] | pin_ptr | Populate the caller's pointer. |
[in] | start_offset | Pin the next record at this offset. Meaningful only for large records. |
[out] | eof | False if the pin_i points to a record, true if there were no next record to pin. |
Reimplemented in append_file_i.
Advance to the first record on the next page in the file.
[out] | pin_ptr | Populate the caller's pointer. This pin_i represents the state of this scan. |
[in] | start_offset | Pin the next record at this offset. This is meaningful only for large records. |
[out] | eof | False if the pin_i points to a record, true if there were no next record to pin. |