Skip to content

Commit b95f3f2

Browse files
authored
clean up public-facing backend code (#744)
* clean up public-facing backend code * format
1 parent 69f851a commit b95f3f2

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

src/include/common/config.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ extern std::atomic<bool> enable_logging;
3030
/** If ENABLE_LOGGING is true, the log should be flushed to disk every LOG_TIMEOUT. */
3131
extern std::chrono::duration<int64_t> log_timeout;
3232

33-
static constexpr int INVALID_PAGE_ID = -1; // invalid page id
34-
static constexpr int INVALID_TXN_ID = -1; // invalid transaction id
35-
static constexpr int INVALID_LSN = -1; // invalid log sequence number
33+
static constexpr int INVALID_FRAME_ID = -1; // invalid frame id
34+
static constexpr int INVALID_PAGE_ID = -1; // invalid page id
35+
static constexpr int INVALID_TXN_ID = -1; // invalid transaction id
36+
static constexpr int INVALID_LSN = -1; // invalid log sequence number
37+
3638
static constexpr int BUSTUB_PAGE_SIZE = 4096; // size of a data page in byte
3739
static constexpr int BUFFER_POOL_SIZE = 10; // size of buffer pool
40+
static constexpr int DEFAULT_DB_IO_SIZE = 16; // starting size of file on disk
3841
static constexpr int LOG_BUFFER_SIZE = ((BUFFER_POOL_SIZE + 1) * BUSTUB_PAGE_SIZE); // size of a log buffer in byte
3942
static constexpr int BUCKET_SIZE = 50; // size of extendible hash bucket
40-
static constexpr int LRUK_REPLACER_K = 10; // default lookback window for lru-k replacer
43+
static constexpr int LRUK_REPLACER_K = 10; // backward k-distance for lru-k
4144

4245
using frame_id_t = int32_t; // frame id type
4346
using page_id_t = int32_t; // page id type

src/include/storage/disk/disk_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ class DiskManager {
121121
std::mutex db_io_latch_;
122122

123123
/** @brief The number of pages allocated to the DBMS on disk. */
124-
size_t pages_;
124+
size_t pages_{0};
125125
/** @brief The capacity of the file used for storage on disk. */
126-
size_t page_capacity_;
126+
size_t page_capacity_{DEFAULT_DB_IO_SIZE};
127127
};
128128

129129
} // namespace bustub

src/include/storage/disk/disk_manager_memory.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: src/include/storage/disk/disk_manager_memory.h
88
//
9-
// Copyright (c) 2015-2020, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2024, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

@@ -34,9 +34,6 @@
3434

3535
namespace bustub {
3636

37-
/** @brief The default size of the database file. */
38-
static const size_t DEFAULT_DB_IO_SIZE = 16;
39-
4037
/**
4138
* DiskManagerMemory replicates the utility of DiskManager on memory. It is primarily used for
4239
* data structure performance testing.
@@ -99,7 +96,6 @@ class DiskManagerUnlimitedMemory : public DiskManager {
9996
while (data_.size() < pages + 1) {
10097
data_.push_back(std::make_shared<ProtectedPage>());
10198
}
102-
assert(data_.size() == pages + 1);
10399

104100
pages_ = pages;
105101
}

src/include/storage/page/page_guard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: src/include/storage/page/page_guard.h
88
//
9-
// Copyright (c) 2024-2024, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2024, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

src/storage/disk/disk_manager.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string>
1919
#include <thread> // NOLINT
2020

21+
#include "common/config.h"
2122
#include "common/exception.h"
2223
#include "common/logger.h"
2324
#include "storage/disk/disk_manager.h"
@@ -26,15 +27,11 @@ namespace bustub {
2627

2728
static char *buffer_used;
2829

29-
/** @brief The default size of the database file. */
30-
static const size_t DEFAULT_DB_IO_SIZE = 16;
31-
3230
/**
3331
* Constructor: open/create a single database file & log file
3432
* @input db_file: database file name
3533
*/
36-
DiskManager::DiskManager(const std::filesystem::path &db_file)
37-
: file_name_(db_file), pages_(0), page_capacity_(DEFAULT_DB_IO_SIZE) {
34+
DiskManager::DiskManager(const std::filesystem::path &db_file) : file_name_(db_file) {
3835
log_name_ = file_name_.filename().stem().string() + ".log";
3936

4037
log_io_.open(log_name_, std::ios::binary | std::ios::in | std::ios::app | std::ios::out);

src/storage/disk/disk_manager_memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: src/storage/disk/disk_manager_memory.cpp
88
//
9-
// Copyright (c) 2015-2020, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2024, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

test/storage/page_guard_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Identification: test/storage/page_guard_test.cpp
88
//
9-
// Copyright (c) 2015-2019, Carnegie Mellon University Database Group
9+
// Copyright (c) 2015-2024, Carnegie Mellon University Database Group
1010
//
1111
//===----------------------------------------------------------------------===//
1212

0 commit comments

Comments
 (0)