finish basic design for BPT

This commit is contained in:
2024-04-27 12:52:45 +00:00
parent 460245ff5e
commit 3d7b616dc7
7 changed files with 192 additions and 52 deletions

View File

@ -1,7 +1,9 @@
#include <gtest/gtest.h>
#include <map>
#include "bpt/bpt.hpp"
#include "bpt/buffer_pool_manager.h"
#include "bpt/config.h"
#include "bpt/disk_manager.h"
namespace bpt_basic_test {
template <size_t length>
class FixLengthString {
@ -9,7 +11,7 @@ class FixLengthString {
char data[length];
};
} // namespace bpt_basic_test
TEST(BasicTest, Compile) {
TEST(BasicTest, Compile) { // This Test only test the compile of the code
// test for long long, int, char, long double
BPlusTreePage<long long> page_long_long;
static_assert(sizeof(page_long_long) == 4096, "BPlusTreePage size mismatch");
@ -37,4 +39,17 @@ TEST(BasicTest, Compile) {
static_assert(sizeof(page_35) == 4096, "BPlusTreePage size mismatch");
BPlusTreePage<bpt_basic_test::FixLengthString<40>> page_40;
static_assert(sizeof(page_40) == 4096, "BPlusTreePage size mismatch");
remove("/tmp/bpt1.db");
DiskManager *dm = new DiskManager("/tmp/bpt1.db");
BufferPoolManager *bpm = new BufferPoolManager(10, 3, dm);
BPlusTreeIndexer<long long, std::less<long long>> bpt(bpm);
auto it = bpt.lower_bound(1);
bpt.Flush();
bpt.Get(1);
it.SetValue(2);
bpt.Put(1, 2);
bpt.Remove(1);
delete bpm;
delete dm;
}

View File

@ -177,7 +177,7 @@ TEST(StoreTest, Test1) {
PageType c;
c.data.p_n = 0x1f2f3f4f;
c.data.key_count = 0x1f2a;
c.data.is_leaf = 0x3e;
c.data.page_status = 0x3e;
c.data.p_data[17].first = 0x8f7f6f5f4f3f2f1f;
c.filler[0] = 0x1f;
*basic_guard.AsMut<PageType>() = c;
@ -263,13 +263,13 @@ TEST(MemoryRiver, T2) {
size_t interal_id_tot = 0;
const unsigned int RndSeed = testing::GTEST_FLAG(random_seed);
std::mt19937 rnd(RndSeed);
remove("/tmp/T2.std");
remove("/tmp/T2.dat");
remove("T2.std");
remove("T2.dat");
const int kInfoLength = 100;
{
sol::MemoryRiver<DataType, kInfoLength> STD("/tmp/T2.std");
MemoryRiver<DataType, kInfoLength> mr("/tmp/T2.dat");
int total_opts = 1000;
int total_opts = 1000000;
while (total_opts-- > 0) {
int opt = rnd() % 6;
switch (opt) {