File tree Expand file tree Collapse file tree 7 files changed +15
-19
lines changed Expand file tree Collapse file tree 7 files changed +15
-19
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,17 @@ extern std::atomic<bool> enable_logging;
30
30
/* * If ENABLE_LOGGING is true, the log should be flushed to disk every LOG_TIMEOUT. */
31
31
extern std::chrono::duration<int64_t > log_timeout;
32
32
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
+
36
38
static constexpr int BUSTUB_PAGE_SIZE = 4096 ; // size of a data page in byte
37
39
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
38
41
static constexpr int LOG_BUFFER_SIZE = ((BUFFER_POOL_SIZE + 1 ) * BUSTUB_PAGE_SIZE); // size of a log buffer in byte
39
42
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
41
44
42
45
using frame_id_t = int32_t ; // frame id type
43
46
using page_id_t = int32_t ; // page id type
Original file line number Diff line number Diff line change @@ -121,9 +121,9 @@ class DiskManager {
121
121
std::mutex db_io_latch_;
122
122
123
123
/* * @brief The number of pages allocated to the DBMS on disk. */
124
- size_t pages_;
124
+ size_t pages_{ 0 } ;
125
125
/* * @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} ;
127
127
};
128
128
129
129
} // namespace bustub
Original file line number Diff line number Diff line change 6
6
//
7
7
// Identification: src/include/storage/disk/disk_manager_memory.h
8
8
//
9
- // Copyright (c) 2015-2020 , Carnegie Mellon University Database Group
9
+ // Copyright (c) 2015-2024 , Carnegie Mellon University Database Group
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
34
34
35
35
namespace bustub {
36
36
37
- /* * @brief The default size of the database file. */
38
- static const size_t DEFAULT_DB_IO_SIZE = 16 ;
39
-
40
37
/* *
41
38
* DiskManagerMemory replicates the utility of DiskManager on memory. It is primarily used for
42
39
* data structure performance testing.
@@ -99,7 +96,6 @@ class DiskManagerUnlimitedMemory : public DiskManager {
99
96
while (data_.size () < pages + 1 ) {
100
97
data_.push_back (std::make_shared<ProtectedPage>());
101
98
}
102
- assert (data_.size () == pages + 1 );
103
99
104
100
pages_ = pages;
105
101
}
Original file line number Diff line number Diff line change 6
6
//
7
7
// Identification: src/include/storage/page/page_guard.h
8
8
//
9
- // Copyright (c) 2024 -2024, Carnegie Mellon University Database Group
9
+ // Copyright (c) 2015 -2024, Carnegie Mellon University Database Group
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
Original file line number Diff line number Diff line change 18
18
#include < string>
19
19
#include < thread> // NOLINT
20
20
21
+ #include " common/config.h"
21
22
#include " common/exception.h"
22
23
#include " common/logger.h"
23
24
#include " storage/disk/disk_manager.h"
@@ -26,15 +27,11 @@ namespace bustub {
26
27
27
28
static char *buffer_used;
28
29
29
- /* * @brief The default size of the database file. */
30
- static const size_t DEFAULT_DB_IO_SIZE = 16 ;
31
-
32
30
/* *
33
31
* Constructor: open/create a single database file & log file
34
32
* @input db_file: database file name
35
33
*/
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) {
38
35
log_name_ = file_name_.filename ().stem ().string () + " .log" ;
39
36
40
37
log_io_.open (log_name_, std::ios::binary | std::ios::in | std::ios::app | std::ios::out);
Original file line number Diff line number Diff line change 6
6
//
7
7
// Identification: src/storage/disk/disk_manager_memory.cpp
8
8
//
9
- // Copyright (c) 2015-2020 , Carnegie Mellon University Database Group
9
+ // Copyright (c) 2015-2024 , Carnegie Mellon University Database Group
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
Original file line number Diff line number Diff line change 6
6
//
7
7
// Identification: test/storage/page_guard_test.cpp
8
8
//
9
- // Copyright (c) 2015-2019 , Carnegie Mellon University Database Group
9
+ // Copyright (c) 2015-2024 , Carnegie Mellon University Database Group
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
You can’t perform that action at this time.
0 commit comments