1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/storage/meta_block_reader.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/common.hpp" |
12 | #include "duckdb/common/serializer.hpp" |
13 | #include "duckdb/storage/block.hpp" |
14 | #include "duckdb/storage/buffer/buffer_handle.hpp" |
15 | |
16 | namespace duckdb { |
17 | class BlockHandle; |
18 | class BlockManager; |
19 | class BufferHandle; |
20 | class DatabaseInstance; |
21 | |
22 | //! This struct is responsible for reading meta data from disk |
23 | class MetaBlockReader : public Deserializer { |
24 | public: |
25 | MetaBlockReader(BlockManager &block_manager, block_id_t block, bool free_blocks_on_read = true); |
26 | ~MetaBlockReader() override; |
27 | |
28 | BlockManager &block_manager; |
29 | shared_ptr<BlockHandle> block; |
30 | BufferHandle handle; |
31 | idx_t offset; |
32 | block_id_t next_block; |
33 | bool free_blocks_on_read; |
34 | |
35 | public: |
36 | //! Read content of size read_size into the buffer |
37 | void ReadData(data_ptr_t buffer, idx_t read_size) override; |
38 | |
39 | ClientContext &GetContext() override; |
40 | optional_ptr<Catalog> GetCatalog() override; |
41 | void SetCatalog(Catalog &catalog_p); |
42 | void SetContext(ClientContext &context_p); |
43 | |
44 | private: |
45 | void ReadNewBlock(block_id_t id); |
46 | optional_ptr<ClientContext> context; |
47 | optional_ptr<Catalog> catalog; |
48 | }; |
49 | } // namespace duckdb |
50 |