Skip to content

Commit

Permalink
fix disk manager read page
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Dec 10, 2024
1 parent ae67d43 commit c73f42f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/storage/disk/disk_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void DiskManager::ReadPage(page_id_t page_id, char *page_data) {
return;
}

pages_[page_id] = offset;

// Set the read cursor to the page offset.
db_io_.seekg(offset);
db_io_.read(page_data, BUSTUB_PAGE_SIZE);
Expand Down
3 changes: 0 additions & 3 deletions test/storage/disk_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ TEST_F(DiskManagerTest, DeletePageTest) {
EXPECT_EQ(std::memcmp(buf, data, sizeof(buf)), 0);

dm.DeletePage(page_id);
std::memset(buf, 0, sizeof(buf));
dm.ReadPage(page_id, buf);
EXPECT_EQ(strlen(buf), 0); // expect empty read
}

// expect no change in file size after delete because we're reclaiming space
Expand Down

0 comments on commit c73f42f

Please sign in to comment.