kkli08 / KV-Store

Key-Value Storage Database
MIT License
1 stars 0 forks source link

`Update` smallest and largest Key value in SSTIndex file #42

Open kkli08 opened 2 weeks ago

kkli08 commented 2 weeks ago

Update page information in Index.sst, and should pass the following unit test once the issue has been solved.

TEST(SSTIndexTest, UpdateExistingSSTInIndex) {
    SSTIndex* index = new SSTIndex();
    index->set_path("test_db");

    index->addSST("sst_1.sst", 10, 100);
    index->addSST("sst_1.sst", 50, 150); // Update with new keys

    std::deque<SSTInfo*> sst_index = index->getSSTsIndex();
    ASSERT_EQ(sst_index.size(), 1);
    EXPECT_EQ(sst_index[0]->filename, "sst_1.sst");
    EXPECT_EQ(sst_index[0]->smallest_key, 50);
    EXPECT_EQ(sst_index[0]->largest_key, 150);

    delete index;
    fs::remove_all("test_db");
}