buffer pool manager passed Memory River Test

This commit is contained in:
2024-04-26 08:50:11 +00:00
parent 8e1d8c7291
commit d47e32e986
7 changed files with 183 additions and 7 deletions

View File

@ -2,9 +2,8 @@
#define BPT_PAGE_HPP
#include <utility>
#include "bpt/config.h"
#pragma pack(push, 1)
template <typename KeyType, size_t kPageSize = 4096>
class BPlusTreePage {
struct ActualDataType {
typedef std::pair<KeyType, default_numeric_index_t> value_type;
page_id_t p_n;
page_id_t p_parent;
@ -13,8 +12,15 @@ class BPlusTreePage {
const static size_t kMaxKeyCount =
(kPageSize - sizeof(page_id_t) * 2 - sizeof(uint8_t) - sizeof(uint16_t)) / sizeof(value_type);
value_type p_data[kMaxKeyCount];
char filler[kPageSize - sizeof(page_id_t) * 2 - sizeof(uint8_t) - sizeof(uint16_t) -
sizeof(value_type) * kMaxKeyCount];
};
#pragma pack(pop)
template <typename KeyType, size_t kPageSize = 4096>
union BPlusTreePage {
inline BPlusTreePage() {}
inline BPlusTreePage &operator=(const BPlusTreePage &that) {
memcpy(this, &that, sizeof(BPlusTreePage));
return *this;
}
ActualDataType<KeyType, kPageSize> data;
char filler[kPageSize];
};
#endif // BPT_PAGE_H

View File

@ -362,6 +362,10 @@ class BufferPoolManager {
/**
* @brief Flush all the pages in the buffer pool to disk.
*
* @warning The buffer pool manager will automatically call FlushAllPages before being destroyed, but if the disk
* manager is closed, it will do nothing. And Page Guard should be destroyed before Buffer Pool Manager, Buffer Pool
* Manager should be destroyed before Disk Manager.
*/
void FlushAllPages();

View File

@ -2,7 +2,7 @@
#define DISK_MANAGER_H
#include <cstdio>
#include <string>
#include "config.h"
#include "bpt/config.h"
class DiskManager {
/**
* The Data Structure on Disk: