Commit ec6fbb67 authored by 天津理工大学11队's avatar 天津理工大学11队
Browse files

feat(rm_scan): 实现题目要求接口

Showing with 23 additions and 2 deletions
+23 -2
......@@ -18,7 +18,9 @@ See the Mulan PSL v2 for more details. */
RmScan::RmScan(const RmFileHandle *file_handle) : file_handle_(file_handle) {
// Todo:
// 初始化file_handle和rid(指向第一个存放了记录的位置)
rid_.page_no = RM_FIRST_RECORD_PAGE;
rid_.slot_no = -1;
next();
}
/**
......@@ -27,7 +29,24 @@ RmScan::RmScan(const RmFileHandle *file_handle) : file_handle_(file_handle) {
void RmScan::next() {
// Todo:
// 找到文件中下一个存放了记录的非空闲位置,用rid_来指向这个位置
if (is_end()) {
return;
}
// for pages
for (; rid_.page_no < this->file_handle_->file_hdr_.num_pages; rid_.page_no++){
rid_.slot_no = Bitmap::next_bit(
true,
file_handle_->fetch_page_handle(rid_.page_no).bitmap,
file_handle_->file_hdr_.num_records_per_page,
rid_.slot_no
);
if (rid_.slot_no < file_handle_->file_hdr_.num_records_per_page) {
return;
}
rid_.slot_no = -1;
}
rid_.page_no = RM_NO_PAGE;
}
/**
......@@ -35,7 +54,9 @@ void RmScan::next() {
*/
bool RmScan::is_end() const {
// Todo: 修改返回值
if (rid_.page_no == RM_NO_PAGE) {
return true;
}
return false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment