Commit 98b3d8ff authored by lepsa's avatar lepsa
Browse files

refact:删除一些没用到的代码

parent c97dbc51
No related merge requests found
Showing with 0 additions and 40 deletions
+0 -40
......@@ -35,44 +35,6 @@ std::unique_ptr<RmRecord> RmFileHandle::get_record(const Rid& rid, Context* cont
return record;
}
void RmFileHandle::massive_insert(const std::vector<std::unique_ptr<RmRecord>> *records, std::vector<Rid> *rids, Context *context) {
if(rids != nullptr) {
assert(rids->size() == 0);
}
int record_size = file_hdr_.record_size;
int record_nums = file_hdr_.num_records_per_page;
RmPageHandle page_hdl = create_page_handle();
for(size_t i = 0; i < records->size(); i++) {
int slot_no = Bitmap::first_bit(false, page_hdl.bitmap, record_nums);
// insert_entry对record加X锁
auto rid = Rid{.page_no = page_hdl.page->get_page_id().page_no, .slot_no = slot_no};
// if(context != nullptr) {
// context->lock_mgr_->lock_exclusive_on_record(context->txn_, rid, fd_);
// }
//
if(rids != nullptr) {
rids->push_back(rid);
}
// 3. 将buf复制到空闲slot位置
char* slot_ptr = page_hdl.get_slot(slot_no);
std::memcpy(slot_ptr, (*records)[i]->data, record_size);
Bitmap::set(page_hdl.bitmap, slot_no);
// 当前page满了,取下一个page
if(++page_hdl.page_hdr->num_records == record_nums){
file_hdr_.first_free_page_no = page_hdl.page_hdr->next_free_page_no;
buffer_pool_manager_->unpin_page(page_hdl.page->get_page_id(), true);
// buffer_pool_manager_->flush_page(page_hdl.page->get_page_id());
page_hdl = create_page_handle();
}
}
buffer_pool_manager_->unpin_page(page_hdl.page->get_page_id(), true);
// flush all pages
// buffer_pool_manager_->flush_page(page_hdl.page->get_page_id());
}
/**
* @description: 在当前表中插入一条记录,不指定插入位置
* @param {char*} buf 要插入的记录的数据
......
......@@ -77,8 +77,6 @@ class RmFileHandle {
std::unique_ptr<RmRecord> get_record(const Rid &rid, Context *context) const;
void massive_insert(const std::vector<std::unique_ptr<RmRecord>> *records, std::vector<Rid> *rids, Context *context);
Rid insert_record(char *buf, Context *context, bool is_load = false);
void insert_record(const Rid &rid, char *buf, Context *context);
......
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