File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,19 +36,22 @@ using ReplacerType = LRUReplacer;
3636class BufferPoolInstance {
3737 private:
3838 static constexpr size_t pool_size_ = BUFFER_POOL_SIZE / BUFFER_POOL_INSTANCE_SIZE; // 缓冲池大小(帧数)
39- Page pages_[pool_size_] ; // 缓冲池中的页面数组,连续分配
39+ Page * pages_; // 缓冲池中的页面数组,连续分配
4040 std::unordered_map<PageId, frame_id_t > page_table_; // 页面到帧的映射表
4141 std::vector<frame_id_t > free_list_; // 空闲帧链表
4242 ReplacerType replacer_; // 页面替换策略实现
4343 std::mutex latch_; // 并发控制锁
4444
4545 public:
4646 BufferPoolInstance () : free_list_(pool_size_) {
47+ pages_ = new Page[pool_size_];
4748 std::iota (free_list_.begin (), free_list_.end (), 0 );
48- page_table_.reserve (pool_size_ * 4 ); // 预留空间,避免频繁扩容
49+ page_table_.reserve (pool_size_ * 3 ); // 预留空间,避免频繁扩容
4950 }
5051
51- ~BufferPoolInstance () = default ;
52+ ~BufferPoolInstance () {
53+ delete[] pages_;
54+ }
5255
5356 /* *
5457 * @description: 将目标页面标记为脏页
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ extern DiskManager disk_manager;
3030 */
3131class BufferPoolManager {
3232 private:
33- static constexpr size_t pool_size_ = BUFFER_POOL_SIZE; // 缓冲池大小(帧数)
3433 BufferPoolInstance buffer_pool_instances_[BUFFER_POOL_INSTANCE_SIZE]; // 缓冲池实例数组
3534
3635 struct PageIdHash {
You can’t perform that action at this time.
0 commit comments