duckdb 0.6.2-dev768.0 → 0.6.2-dev772.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +5 -1
- package/src/duckdb/src/storage/buffer_manager.cpp +9 -1
- package/src/duckdb/src/storage/meta_block_reader.cpp +1 -1
- package/src/duckdb/src/storage/storage_manager.cpp +2 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev772"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "ec4a46083e"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -65,7 +65,9 @@ public:
|
|
|
65
65
|
virtual idx_t FreeBlocks() = 0;
|
|
66
66
|
|
|
67
67
|
//! Register a block with the given block id in the base file
|
|
68
|
-
shared_ptr<BlockHandle> RegisterBlock(block_id_t block_id);
|
|
68
|
+
shared_ptr<BlockHandle> RegisterBlock(block_id_t block_id, bool is_meta_block = false);
|
|
69
|
+
//! Clear cached handles for meta blocks
|
|
70
|
+
void ClearMetaBlockHandles();
|
|
69
71
|
//! Convert an existing in-memory buffer into a persistent disk-backed block
|
|
70
72
|
shared_ptr<BlockHandle> ConvertToPersistent(block_id_t block_id, shared_ptr<BlockHandle> old_block);
|
|
71
73
|
|
|
@@ -79,5 +81,7 @@ private:
|
|
|
79
81
|
mutex blocks_lock;
|
|
80
82
|
//! A mapping of block id -> BlockHandle
|
|
81
83
|
unordered_map<block_id_t, weak_ptr<BlockHandle>> blocks;
|
|
84
|
+
//! A map to cache the BlockHandles of meta blocks
|
|
85
|
+
unordered_map<block_id_t, shared_ptr<BlockHandle>> meta_blocks;
|
|
82
86
|
};
|
|
83
87
|
} // namespace duckdb
|
|
@@ -249,7 +249,7 @@ BufferManager::BufferManager(DatabaseInstance &db, string tmp, idx_t maximum_mem
|
|
|
249
249
|
BufferManager::~BufferManager() {
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
shared_ptr<BlockHandle> BlockManager::RegisterBlock(block_id_t block_id) {
|
|
252
|
+
shared_ptr<BlockHandle> BlockManager::RegisterBlock(block_id_t block_id, bool is_meta_block) {
|
|
253
253
|
lock_guard<mutex> lock(blocks_lock);
|
|
254
254
|
// check if the block already exists
|
|
255
255
|
auto entry = blocks.find(block_id);
|
|
@@ -263,11 +263,19 @@ shared_ptr<BlockHandle> BlockManager::RegisterBlock(block_id_t block_id) {
|
|
|
263
263
|
}
|
|
264
264
|
// create a new block pointer for this block
|
|
265
265
|
auto result = make_shared<BlockHandle>(*this, block_id);
|
|
266
|
+
// for meta block, cache the handle in meta_blocks
|
|
267
|
+
if (is_meta_block) {
|
|
268
|
+
meta_blocks[block_id] = result;
|
|
269
|
+
}
|
|
266
270
|
// register the block pointer in the set of blocks as a weak pointer
|
|
267
271
|
blocks[block_id] = weak_ptr<BlockHandle>(result);
|
|
268
272
|
return result;
|
|
269
273
|
}
|
|
270
274
|
|
|
275
|
+
void BlockManager::ClearMetaBlockHandles() {
|
|
276
|
+
meta_blocks.clear();
|
|
277
|
+
}
|
|
278
|
+
|
|
271
279
|
shared_ptr<BlockHandle> BlockManager::ConvertToPersistent(block_id_t block_id, shared_ptr<BlockHandle> old_block) {
|
|
272
280
|
|
|
273
281
|
// pin the old block to ensure we have it loaded in memory
|
|
@@ -44,7 +44,7 @@ void MetaBlockReader::ReadNewBlock(block_id_t id) {
|
|
|
44
44
|
if (free_blocks_on_read) {
|
|
45
45
|
block_manager.MarkBlockAsModified(id);
|
|
46
46
|
}
|
|
47
|
-
block = block_manager.RegisterBlock(id);
|
|
47
|
+
block = block_manager.RegisterBlock(id, true);
|
|
48
48
|
handle = buffer_manager.Pin(block);
|
|
49
49
|
|
|
50
50
|
next_block = Load<block_id_t>(handle.Ptr());
|
|
@@ -136,6 +136,8 @@ void SingleFileStorageManager::LoadDatabase() {
|
|
|
136
136
|
//! Load from storage
|
|
137
137
|
auto checkpointer = SingleFileCheckpointReader(*this);
|
|
138
138
|
checkpointer.LoadFromStorage();
|
|
139
|
+
// finish load checkpoint, clear the cached handles of meta blocks
|
|
140
|
+
block_manager->ClearMetaBlockHandles();
|
|
139
141
|
// check if the WAL file exists
|
|
140
142
|
if (fs.FileExists(wal_path)) {
|
|
141
143
|
// replay the WAL
|