1#include "duckdb/storage/checkpoint/table_data_writer.hpp"
2
3#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
4#include "duckdb/common/vector_operations/vector_operations.hpp"
5#include "duckdb/common/serializer/buffered_serializer.hpp"
6#include "duckdb/storage/table/column_checkpoint_state.hpp"
7
8namespace duckdb {
9
10CompressionType RowGroupWriter::GetColumnCompressionType(idx_t i) {
11 return table.GetColumn(idx: LogicalIndex(i)).CompressionType();
12}
13
14void RowGroupWriter::RegisterPartialBlock(PartialBlockAllocation &&allocation) {
15 partial_block_manager.RegisterPartialBlock(allocation: std::move(allocation));
16}
17
18PartialBlockAllocation RowGroupWriter::GetBlockAllocation(uint32_t segment_size) {
19 return partial_block_manager.GetBlockAllocation(segment_size);
20}
21
22void SingleFileRowGroupWriter::WriteColumnDataPointers(ColumnCheckpointState &column_checkpoint_state) {
23 auto &meta_writer = table_data_writer;
24 const auto &data_pointers = column_checkpoint_state.data_pointers;
25
26 meta_writer.Write<idx_t>(element: data_pointers.size());
27 // then write the data pointers themselves
28 for (idx_t k = 0; k < data_pointers.size(); k++) {
29 auto &data_pointer = data_pointers[k];
30 meta_writer.Write<idx_t>(element: data_pointer.row_start);
31 meta_writer.Write<idx_t>(element: data_pointer.tuple_count);
32 meta_writer.Write<block_id_t>(element: data_pointer.block_pointer.block_id);
33 meta_writer.Write<uint32_t>(element: data_pointer.block_pointer.offset);
34 meta_writer.Write<CompressionType>(element: data_pointer.compression_type);
35 data_pointer.statistics.Serialize(serializer&: meta_writer);
36 }
37}
38
39MetaBlockWriter &SingleFileRowGroupWriter::GetPayloadWriter() {
40 return table_data_writer;
41}
42
43} // namespace duckdb
44