duckdb 0.8.2-dev3458.0 → 0.8.2-dev3949.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/binding.gyp +2 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu_extension.cpp +5 -5
- package/src/duckdb/extension/json/include/json_deserializer.hpp +7 -16
- package/src/duckdb/extension/json/include/json_serializer.hpp +9 -15
- package/src/duckdb/extension/json/json_deserializer.cpp +29 -67
- package/src/duckdb/extension/json/json_scan.cpp +1 -1
- package/src/duckdb/extension/json/json_serializer.cpp +26 -69
- package/src/duckdb/src/common/enum_util.cpp +119 -7
- package/src/duckdb/src/common/extra_type_info.cpp +7 -3
- package/src/duckdb/src/common/radix_partitioning.cpp +8 -31
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +18 -3
- package/src/duckdb/src/common/serializer/binary_deserializer.cpp +62 -77
- package/src/duckdb/src/common/serializer/binary_serializer.cpp +84 -84
- package/src/duckdb/src/common/serializer/format_serializer.cpp +1 -1
- package/src/duckdb/src/common/sort/partition_state.cpp +41 -33
- package/src/duckdb/src/common/types/data_chunk.cpp +44 -8
- package/src/duckdb/src/common/types/hyperloglog.cpp +21 -0
- package/src/duckdb/src/common/types/interval.cpp +3 -0
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +252 -126
- package/src/duckdb/src/common/types/row/row_layout.cpp +3 -31
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +40 -32
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +39 -26
- package/src/duckdb/src/common/types/row/tuple_data_layout.cpp +11 -1
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +21 -16
- package/src/duckdb/src/common/types/value.cpp +63 -42
- package/src/duckdb/src/common/types/vector.cpp +33 -67
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +3 -2
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +222 -364
- package/src/duckdb/src/execution/join_hashtable.cpp +5 -6
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +240 -310
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +202 -173
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +36 -2
- package/src/duckdb/src/execution/operator/{persistent → csv_scanner}/base_csv_reader.cpp +58 -162
- package/src/duckdb/src/execution/operator/csv_scanner/buffered_csv_reader.cpp +434 -0
- package/src/duckdb/src/execution/operator/csv_scanner/csv_buffer.cpp +80 -0
- package/src/duckdb/src/execution/operator/csv_scanner/csv_buffer_manager.cpp +90 -0
- package/src/duckdb/src/execution/operator/csv_scanner/csv_file_handle.cpp +95 -0
- package/src/duckdb/src/execution/operator/{persistent → csv_scanner}/csv_reader_options.cpp +47 -28
- package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine.cpp +35 -0
- package/src/duckdb/src/execution/operator/csv_scanner/csv_state_machine_cache.cpp +107 -0
- package/src/duckdb/src/execution/operator/{persistent → csv_scanner}/parallel_csv_reader.cpp +44 -44
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +52 -0
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +336 -0
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +165 -0
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +398 -0
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_refinement.cpp +175 -0
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +39 -0
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +1 -2
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +614 -574
- package/src/duckdb/src/execution/window_executor.cpp +6 -5
- package/src/duckdb/src/function/cast/cast_function_set.cpp +1 -0
- package/src/duckdb/src/function/scalar/strftime_format.cpp +4 -4
- package/src/duckdb/src/function/table/copy_csv.cpp +94 -96
- package/src/duckdb/src/function/table/read_csv.cpp +150 -136
- package/src/duckdb/src/function/table/table_scan.cpp +0 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +24 -0
- package/src/duckdb/src/include/duckdb/common/file_opener.hpp +9 -0
- package/src/duckdb/src/include/duckdb/common/fixed_size_map.hpp +208 -0
- package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/printer.hpp +11 -0
- package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +43 -30
- package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +36 -35
- package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +18 -0
- package/src/duckdb/src/include/duckdb/common/serializer/encoding_util.hpp +132 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +125 -150
- package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +119 -107
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/shared_ptr.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +13 -7
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +5 -0
- package/src/duckdb/src/include/duckdb/common/types/hyperloglog.hpp +7 -1
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +7 -0
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +41 -9
- package/src/duckdb/src/include/duckdb/common/types/row/row_data_collection_scanner.hpp +5 -0
- package/src/duckdb/src/include/duckdb/common/types/row/row_layout.hpp +1 -23
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +14 -8
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +6 -3
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_layout.hpp +7 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +13 -8
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/vector.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +125 -146
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +4 -3
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent → scan/csv}/base_csv_reader.hpp +17 -17
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/buffered_csv_reader.hpp +72 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_buffer.hpp +110 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_buffer_manager.hpp +103 -0
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent → scan/csv}/csv_file_handle.hpp +8 -15
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent → scan/csv}/csv_line_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent → scan/csv}/csv_reader_options.hpp +52 -28
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_sniffer.hpp +127 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_state_machine.hpp +75 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/csv_state_machine_cache.hpp +51 -0
- package/src/duckdb/src/include/duckdb/execution/operator/{persistent → scan/csv}/parallel_csv_reader.hpp +21 -27
- package/src/duckdb/src/include/duckdb/execution/operator/scan/csv/quote_rules.hpp +21 -0
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +18 -27
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +5 -6
- package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +17 -12
- package/src/duckdb/src/include/duckdb/main/client_context_file_opener.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/connection.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/relation/read_csv_relation.hpp +6 -6
- package/src/duckdb/src/include/duckdb/parallel/event.hpp +12 -1
- package/src/duckdb/src/include/duckdb/storage/block.hpp +6 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +7 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +5 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/list_stats.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_stats.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +15 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +5 -0
- package/src/duckdb/src/include/duckdb/verification/deserialized_statement_verifier_v2.hpp +6 -0
- package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +1 -0
- package/src/duckdb/src/include/duckdb.h +12 -0
- package/src/duckdb/src/main/capi/logical_types-c.cpp +22 -0
- package/src/duckdb/src/main/client_context_file_opener.cpp +17 -0
- package/src/duckdb/src/main/client_verify.cpp +1 -0
- package/src/duckdb/src/main/config.cpp +2 -2
- package/src/duckdb/src/main/connection.cpp +3 -3
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +19 -13
- package/src/duckdb/src/parallel/pipeline_finish_event.cpp +1 -1
- package/src/duckdb/src/parser/tableref/pivotref.cpp +0 -16
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +41 -25
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +10 -10
- package/src/duckdb/src/planner/logical_operator.cpp +1 -1
- package/src/duckdb/src/planner/planner.cpp +1 -1
- package/src/duckdb/src/storage/checkpoint_manager.cpp +4 -3
- package/src/duckdb/src/storage/serialization/serialize_constraint.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +5 -5
- package/src/duckdb/src/storage/serialization/serialize_expression.cpp +10 -10
- package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +20 -20
- package/src/duckdb/src/storage/serialization/serialize_macro_function.cpp +2 -2
- package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +118 -89
- package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +27 -27
- package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +16 -16
- package/src/duckdb/src/storage/serialization/serialize_result_modifier.cpp +8 -8
- package/src/duckdb/src/storage/serialization/serialize_statement.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_storage.cpp +39 -0
- package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +9 -9
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +67 -4
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +16 -0
- package/src/duckdb/src/storage/statistics/list_stats.cpp +21 -0
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +126 -1
- package/src/duckdb/src/storage/statistics/string_stats.cpp +23 -0
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +27 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/chunk_info.cpp +82 -3
- package/src/duckdb/src/storage/table/row_group.cpp +68 -1
- package/src/duckdb/src/storage/table/table_statistics.cpp +21 -0
- package/src/duckdb/src/storage/wal_replay.cpp +2 -2
- package/src/duckdb/src/verification/deserialized_statement_verifier_v2.cpp +15 -1
- package/src/duckdb/src/verification/statement_verifier.cpp +2 -0
- package/src/duckdb/third_party/utf8proc/include/utf8proc_wrapper.hpp +8 -0
- package/src/duckdb/ub_src_execution.cpp +0 -2
- package/src/duckdb/ub_src_execution_operator_csv_scanner.cpp +18 -0
- package/src/duckdb/ub_src_execution_operator_csv_scanner_sniffer.cpp +12 -0
- package/src/duckdb/ub_src_execution_operator_persistent.cpp +0 -12
- package/src/duckdb/ub_src_storage_serialization.cpp +2 -0
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +0 -1487
- package/src/duckdb/src/execution/operator/persistent/csv_buffer.cpp +0 -72
- package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +0 -158
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +0 -207
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -133
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_buffer.hpp +0 -74
- package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +0 -73
@@ -0,0 +1,39 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// This file is automatically generated by scripts/generate_serialization.py
|
3
|
+
// Do not edit this file manually, your changes will be overwritten
|
4
|
+
//===----------------------------------------------------------------------===//
|
5
|
+
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
#include "duckdb/storage/block.hpp"
|
9
|
+
#include "duckdb/storage/statistics/distinct_statistics.hpp"
|
10
|
+
|
11
|
+
namespace duckdb {
|
12
|
+
|
13
|
+
void DistinctStatistics::FormatSerialize(FormatSerializer &serializer) const {
|
14
|
+
serializer.WriteProperty(100, "sample_count", sample_count);
|
15
|
+
serializer.WriteProperty(101, "total_count", total_count);
|
16
|
+
serializer.WriteProperty(102, "log", log);
|
17
|
+
}
|
18
|
+
|
19
|
+
unique_ptr<DistinctStatistics> DistinctStatistics::FormatDeserialize(FormatDeserializer &deserializer) {
|
20
|
+
auto sample_count = deserializer.ReadProperty<idx_t>(100, "sample_count");
|
21
|
+
auto total_count = deserializer.ReadProperty<idx_t>(101, "total_count");
|
22
|
+
auto log = deserializer.ReadProperty<unique_ptr<HyperLogLog>>(102, "log");
|
23
|
+
auto result = duckdb::unique_ptr<DistinctStatistics>(new DistinctStatistics(std::move(log), sample_count, total_count));
|
24
|
+
return result;
|
25
|
+
}
|
26
|
+
|
27
|
+
void MetaBlockPointer::FormatSerialize(FormatSerializer &serializer) const {
|
28
|
+
serializer.WriteProperty(100, "block_pointer", block_pointer);
|
29
|
+
serializer.WriteProperty(101, "offset", offset);
|
30
|
+
}
|
31
|
+
|
32
|
+
MetaBlockPointer MetaBlockPointer::FormatDeserialize(FormatDeserializer &deserializer) {
|
33
|
+
auto block_pointer = deserializer.ReadProperty<idx_t>(100, "block_pointer");
|
34
|
+
auto offset = deserializer.ReadProperty<uint32_t>(101, "offset");
|
35
|
+
MetaBlockPointer result(block_pointer, offset);
|
36
|
+
return result;
|
37
|
+
}
|
38
|
+
|
39
|
+
} // namespace duckdb
|
@@ -12,13 +12,13 @@ namespace duckdb {
|
|
12
12
|
void TableRef::FormatSerialize(FormatSerializer &serializer) const {
|
13
13
|
serializer.WriteProperty(100, "type", type);
|
14
14
|
serializer.WriteProperty(101, "alias", alias);
|
15
|
-
serializer.
|
15
|
+
serializer.WritePropertyWithDefault(102, "sample", sample, unique_ptr<SampleOptions>());
|
16
16
|
}
|
17
17
|
|
18
18
|
unique_ptr<TableRef> TableRef::FormatDeserialize(FormatDeserializer &deserializer) {
|
19
19
|
auto type = deserializer.ReadProperty<TableReferenceType>(100, "type");
|
20
20
|
auto alias = deserializer.ReadProperty<string>(101, "alias");
|
21
|
-
auto sample = deserializer.
|
21
|
+
auto sample = deserializer.ReadPropertyWithDefault<unique_ptr<SampleOptions>>(102, "sample", unique_ptr<SampleOptions>());
|
22
22
|
unique_ptr<TableRef> result;
|
23
23
|
switch (type) {
|
24
24
|
case TableReferenceType::BASE_TABLE:
|
@@ -93,9 +93,9 @@ unique_ptr<TableRef> ExpressionListRef::FormatDeserialize(FormatDeserializer &de
|
|
93
93
|
|
94
94
|
void JoinRef::FormatSerialize(FormatSerializer &serializer) const {
|
95
95
|
TableRef::FormatSerialize(serializer);
|
96
|
-
serializer.WriteProperty(200, "left",
|
97
|
-
serializer.WriteProperty(201, "right",
|
98
|
-
serializer.
|
96
|
+
serializer.WriteProperty(200, "left", left);
|
97
|
+
serializer.WriteProperty(201, "right", right);
|
98
|
+
serializer.WritePropertyWithDefault(202, "condition", condition, unique_ptr<ParsedExpression>());
|
99
99
|
serializer.WriteProperty(203, "join_type", type);
|
100
100
|
serializer.WriteProperty(204, "ref_type", ref_type);
|
101
101
|
serializer.WriteProperty(205, "using_columns", using_columns);
|
@@ -105,7 +105,7 @@ unique_ptr<TableRef> JoinRef::FormatDeserialize(FormatDeserializer &deserializer
|
|
105
105
|
auto result = duckdb::unique_ptr<JoinRef>(new JoinRef());
|
106
106
|
deserializer.ReadProperty(200, "left", result->left);
|
107
107
|
deserializer.ReadProperty(201, "right", result->right);
|
108
|
-
deserializer.
|
108
|
+
deserializer.ReadPropertyWithDefault(202, "condition", result->condition, unique_ptr<ParsedExpression>());
|
109
109
|
deserializer.ReadProperty(203, "join_type", result->type);
|
110
110
|
deserializer.ReadProperty(204, "ref_type", result->ref_type);
|
111
111
|
deserializer.ReadProperty(205, "using_columns", result->using_columns);
|
@@ -114,7 +114,7 @@ unique_ptr<TableRef> JoinRef::FormatDeserialize(FormatDeserializer &deserializer
|
|
114
114
|
|
115
115
|
void PivotRef::FormatSerialize(FormatSerializer &serializer) const {
|
116
116
|
TableRef::FormatSerialize(serializer);
|
117
|
-
serializer.WriteProperty(200, "source",
|
117
|
+
serializer.WriteProperty(200, "source", source);
|
118
118
|
serializer.WriteProperty(201, "aggregates", aggregates);
|
119
119
|
serializer.WriteProperty(202, "unpivot_names", unpivot_names);
|
120
120
|
serializer.WriteProperty(203, "pivots", pivots);
|
@@ -137,7 +137,7 @@ unique_ptr<TableRef> PivotRef::FormatDeserialize(FormatDeserializer &deserialize
|
|
137
137
|
|
138
138
|
void SubqueryRef::FormatSerialize(FormatSerializer &serializer) const {
|
139
139
|
TableRef::FormatSerialize(serializer);
|
140
|
-
serializer.WriteProperty(200, "subquery",
|
140
|
+
serializer.WriteProperty(200, "subquery", subquery);
|
141
141
|
serializer.WriteProperty(201, "column_name_alias", column_name_alias);
|
142
142
|
}
|
143
143
|
|
@@ -150,7 +150,7 @@ unique_ptr<TableRef> SubqueryRef::FormatDeserialize(FormatDeserializer &deserial
|
|
150
150
|
|
151
151
|
void TableFunctionRef::FormatSerialize(FormatSerializer &serializer) const {
|
152
152
|
TableRef::FormatSerialize(serializer);
|
153
|
-
serializer.WriteProperty(200, "function",
|
153
|
+
serializer.WriteProperty(200, "function", function);
|
154
154
|
serializer.WriteProperty(201, "column_name_alias", column_name_alias);
|
155
155
|
}
|
156
156
|
|
@@ -6,6 +6,9 @@
|
|
6
6
|
#include "duckdb/storage/statistics/list_stats.hpp"
|
7
7
|
#include "duckdb/storage/statistics/struct_stats.hpp"
|
8
8
|
|
9
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
10
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
11
|
+
|
9
12
|
namespace duckdb {
|
10
13
|
|
11
14
|
BaseStatistics::BaseStatistics() : type(LogicalType::INVALID) {
|
@@ -267,6 +270,10 @@ void BaseStatistics::CopyValidity(BaseStatistics &stats) {
|
|
267
270
|
has_no_null = stats.has_no_null;
|
268
271
|
}
|
269
272
|
|
273
|
+
void BaseStatistics::SetDistinctCount(idx_t count) {
|
274
|
+
this->distinct_count = count;
|
275
|
+
}
|
276
|
+
|
270
277
|
void BaseStatistics::Serialize(Serializer &serializer) const {
|
271
278
|
FieldWriter writer(serializer);
|
272
279
|
writer.WriteField<bool>(has_null);
|
@@ -276,10 +283,6 @@ void BaseStatistics::Serialize(Serializer &serializer) const {
|
|
276
283
|
writer.Finalize();
|
277
284
|
}
|
278
285
|
|
279
|
-
void BaseStatistics::SetDistinctCount(idx_t count) {
|
280
|
-
this->distinct_count = count;
|
281
|
-
}
|
282
|
-
|
283
286
|
void BaseStatistics::Serialize(FieldWriter &writer) const {
|
284
287
|
switch (GetStatsType()) {
|
285
288
|
case StatisticsType::NUMERIC_STATS:
|
@@ -298,6 +301,66 @@ void BaseStatistics::Serialize(FieldWriter &writer) const {
|
|
298
301
|
break;
|
299
302
|
}
|
300
303
|
}
|
304
|
+
|
305
|
+
void BaseStatistics::FormatSerialize(FormatSerializer &serializer) const {
|
306
|
+
serializer.WriteProperty(100, "has_null", has_null);
|
307
|
+
serializer.WriteProperty(101, "has_no_null", has_no_null);
|
308
|
+
serializer.WriteProperty(102, "distinct_count", distinct_count);
|
309
|
+
serializer.WriteProperty(103, "stats_type", GetStatsType());
|
310
|
+
serializer.WriteObject(104, "stats", [this](FormatSerializer &serializer) {
|
311
|
+
switch (GetStatsType()) {
|
312
|
+
case StatisticsType::NUMERIC_STATS:
|
313
|
+
NumericStats::FormatSerialize(*this, serializer);
|
314
|
+
break;
|
315
|
+
case StatisticsType::STRING_STATS:
|
316
|
+
StringStats::FormatSerialize(*this, serializer);
|
317
|
+
break;
|
318
|
+
case StatisticsType::LIST_STATS:
|
319
|
+
ListStats::FormatSerialize(*this, serializer);
|
320
|
+
break;
|
321
|
+
case StatisticsType::STRUCT_STATS:
|
322
|
+
StructStats::FormatSerialize(*this, serializer);
|
323
|
+
break;
|
324
|
+
default:
|
325
|
+
throw NotImplementedException("Unrecognized StatisticsType for BaseStatistics::FormatSerialize");
|
326
|
+
}
|
327
|
+
});
|
328
|
+
}
|
329
|
+
|
330
|
+
BaseStatistics BaseStatistics::FormatDeserialize(FormatDeserializer &deserializer) {
|
331
|
+
auto has_null = deserializer.ReadProperty<bool>(100, "has_null");
|
332
|
+
auto has_no_null = deserializer.ReadProperty<bool>(101, "has_no_null");
|
333
|
+
auto distinct_count = deserializer.ReadProperty<idx_t>(102, "distinct_count");
|
334
|
+
|
335
|
+
// Get the logical type from the deserializer context.
|
336
|
+
auto type = deserializer.Get<LogicalType &>();
|
337
|
+
|
338
|
+
BaseStatistics stats;
|
339
|
+
switch (GetStatsType(type)) {
|
340
|
+
case StatisticsType::NUMERIC_STATS:
|
341
|
+
stats = NumericStats::FormatDeserialize(deserializer, type);
|
342
|
+
break;
|
343
|
+
case StatisticsType::STRING_STATS:
|
344
|
+
stats = StringStats::FormatDeserialize(deserializer, type);
|
345
|
+
break;
|
346
|
+
case StatisticsType::LIST_STATS:
|
347
|
+
stats = ListStats::FormatDeserialize(deserializer, type);
|
348
|
+
break;
|
349
|
+
case StatisticsType::STRUCT_STATS:
|
350
|
+
stats = StructStats::FormatDeserialize(deserializer, type);
|
351
|
+
break;
|
352
|
+
default:
|
353
|
+
stats = BaseStatistics(std::move(type));
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
|
357
|
+
stats.has_null = has_null;
|
358
|
+
stats.has_no_null = has_no_null;
|
359
|
+
stats.distinct_count = distinct_count;
|
360
|
+
|
361
|
+
return stats;
|
362
|
+
}
|
363
|
+
|
301
364
|
BaseStatistics BaseStatistics::DeserializeType(FieldReader &reader, LogicalType type) {
|
302
365
|
switch (GetStatsType(type)) {
|
303
366
|
case StatisticsType::NUMERIC_STATS:
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/storage/statistics/column_statistics.hpp"
|
2
2
|
#include "duckdb/common/serializer.hpp"
|
3
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
4
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -64,4 +66,18 @@ shared_ptr<ColumnStatistics> ColumnStatistics::Deserialize(Deserializer &source,
|
|
64
66
|
return make_shared<ColumnStatistics>(stats.Copy(), std::move(distinct_stats));
|
65
67
|
}
|
66
68
|
|
69
|
+
void ColumnStatistics::FormatSerialize(FormatSerializer &serializer) const {
|
70
|
+
serializer.WriteProperty(100, "statistics", stats);
|
71
|
+
serializer.WritePropertyWithDefault(101, "distinct", distinct_stats, unique_ptr<DistinctStatistics>());
|
72
|
+
}
|
73
|
+
|
74
|
+
shared_ptr<ColumnStatistics> ColumnStatistics::FormatDeserialize(FormatDeserializer &deserializer) {
|
75
|
+
// TODO: do we read this as an property or into the object itself?
|
76
|
+
// we have this sort of pseudo inheritance going on here which is annoying
|
77
|
+
auto stats = BaseStatistics::FormatDeserialize(deserializer);
|
78
|
+
auto distinct_stats = deserializer.ReadPropertyWithDefault<unique_ptr<DistinctStatistics>>(
|
79
|
+
101, "distinct", unique_ptr<DistinctStatistics>());
|
80
|
+
return make_shared<ColumnStatistics>(stats.Copy(), std::move(distinct_stats));
|
81
|
+
}
|
82
|
+
|
67
83
|
} // namespace duckdb
|
@@ -4,6 +4,9 @@
|
|
4
4
|
#include "duckdb/common/string_util.hpp"
|
5
5
|
#include "duckdb/common/types/vector.hpp"
|
6
6
|
|
7
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
8
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
9
|
+
|
7
10
|
namespace duckdb {
|
8
11
|
|
9
12
|
void ListStats::Construct(BaseStatistics &stats) {
|
@@ -79,6 +82,24 @@ BaseStatistics ListStats::Deserialize(FieldReader &reader, LogicalType type) {
|
|
79
82
|
return result;
|
80
83
|
}
|
81
84
|
|
85
|
+
void ListStats::FormatSerialize(const BaseStatistics &stats, FormatSerializer &serializer) {
|
86
|
+
auto &child_stats = ListStats::GetChildStats(stats);
|
87
|
+
serializer.WriteProperty(200, "child_stats", child_stats);
|
88
|
+
}
|
89
|
+
|
90
|
+
BaseStatistics ListStats::FormatDeserialize(FormatDeserializer &deserializer, LogicalType type) {
|
91
|
+
D_ASSERT(type.InternalType() == PhysicalType::LIST);
|
92
|
+
auto &child_type = ListType::GetChildType(type);
|
93
|
+
BaseStatistics result(std::move(type));
|
94
|
+
|
95
|
+
// Push the logical type of the child type to the deserialization context
|
96
|
+
deserializer.Set<LogicalType &>(const_cast<LogicalType &>(child_type));
|
97
|
+
result.child_stats[0].Copy(deserializer.ReadProperty<BaseStatistics>(200, "child_stats"));
|
98
|
+
deserializer.Unset<LogicalType>();
|
99
|
+
|
100
|
+
return result;
|
101
|
+
}
|
102
|
+
|
82
103
|
string ListStats::ToString(const BaseStatistics &stats) {
|
83
104
|
auto &child_stats = ListStats::GetChildStats(stats);
|
84
105
|
return StringUtil::Format("[%s]", child_stats.ToString());
|
@@ -4,6 +4,9 @@
|
|
4
4
|
#include "duckdb/common/types/vector.hpp"
|
5
5
|
#include "duckdb/common/operator/comparison_operators.hpp"
|
6
6
|
|
7
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
8
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
9
|
+
|
7
10
|
namespace duckdb {
|
8
11
|
|
9
12
|
template <>
|
@@ -403,7 +406,8 @@ Value NumericStats::MaxOrNull(const BaseStatistics &stats) {
|
|
403
406
|
return NumericStats::Max(stats);
|
404
407
|
}
|
405
408
|
|
406
|
-
void SerializeNumericStatsValue(const LogicalType &type, NumericValueUnion val, bool has_value,
|
409
|
+
static void SerializeNumericStatsValue(const LogicalType &type, NumericValueUnion val, bool has_value,
|
410
|
+
FieldWriter &writer) {
|
407
411
|
writer.WriteField<bool>(!has_value);
|
408
412
|
if (!has_value) {
|
409
413
|
return;
|
@@ -514,6 +518,127 @@ BaseStatistics NumericStats::Deserialize(FieldReader &reader, LogicalType type)
|
|
514
518
|
return result;
|
515
519
|
}
|
516
520
|
|
521
|
+
static void FormatSerializeNumericStatsValue(const LogicalType &type, NumericValueUnion val, bool has_value,
|
522
|
+
FormatSerializer &serializer) {
|
523
|
+
serializer.WriteProperty(100, "has_value", has_value);
|
524
|
+
if (!has_value) {
|
525
|
+
return;
|
526
|
+
}
|
527
|
+
switch (type.InternalType()) {
|
528
|
+
case PhysicalType::BOOL:
|
529
|
+
serializer.WriteProperty(101, "value", val.value_.boolean);
|
530
|
+
break;
|
531
|
+
case PhysicalType::INT8:
|
532
|
+
serializer.WriteProperty(101, "value", val.value_.tinyint);
|
533
|
+
break;
|
534
|
+
case PhysicalType::INT16:
|
535
|
+
serializer.WriteProperty(101, "value", val.value_.smallint);
|
536
|
+
break;
|
537
|
+
case PhysicalType::INT32:
|
538
|
+
serializer.WriteProperty(101, "value", val.value_.integer);
|
539
|
+
break;
|
540
|
+
case PhysicalType::INT64:
|
541
|
+
serializer.WriteProperty(101, "value", val.value_.bigint);
|
542
|
+
break;
|
543
|
+
case PhysicalType::UINT8:
|
544
|
+
serializer.WriteProperty(101, "value", val.value_.utinyint);
|
545
|
+
break;
|
546
|
+
case PhysicalType::UINT16:
|
547
|
+
serializer.WriteProperty(101, "value", val.value_.usmallint);
|
548
|
+
break;
|
549
|
+
case PhysicalType::UINT32:
|
550
|
+
serializer.WriteProperty(101, "value", val.value_.uinteger);
|
551
|
+
break;
|
552
|
+
case PhysicalType::UINT64:
|
553
|
+
serializer.WriteProperty(101, "value", val.value_.ubigint);
|
554
|
+
break;
|
555
|
+
case PhysicalType::INT128:
|
556
|
+
serializer.WriteProperty(101, "value", val.value_.hugeint);
|
557
|
+
break;
|
558
|
+
case PhysicalType::FLOAT:
|
559
|
+
serializer.WriteProperty(101, "value", val.value_.float_);
|
560
|
+
break;
|
561
|
+
case PhysicalType::DOUBLE:
|
562
|
+
serializer.WriteProperty(101, "value", val.value_.double_);
|
563
|
+
break;
|
564
|
+
default:
|
565
|
+
throw InternalException("Unsupported type for serializing numeric statistics");
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
569
|
+
void NumericStats::FormatSerialize(const BaseStatistics &stats, FormatSerializer &serializer) {
|
570
|
+
auto &numeric_stats = NumericStats::GetDataUnsafe(stats);
|
571
|
+
serializer.WriteObject(200, "max", [&](FormatSerializer &object) {
|
572
|
+
FormatSerializeNumericStatsValue(stats.GetType(), numeric_stats.min, numeric_stats.has_min, object);
|
573
|
+
});
|
574
|
+
serializer.WriteObject(201, "min", [&](FormatSerializer &object) {
|
575
|
+
FormatSerializeNumericStatsValue(stats.GetType(), numeric_stats.max, numeric_stats.has_max, object);
|
576
|
+
});
|
577
|
+
}
|
578
|
+
|
579
|
+
static void FormatDeserializeNumericStatsValue(const LogicalType &type, NumericValueUnion &result, bool &has_stats,
|
580
|
+
FormatDeserializer &deserializer) {
|
581
|
+
auto has_value = deserializer.ReadProperty<bool>(100, "has_value");
|
582
|
+
if (!has_value) {
|
583
|
+
has_stats = false;
|
584
|
+
return;
|
585
|
+
}
|
586
|
+
has_stats = true;
|
587
|
+
switch (type.InternalType()) {
|
588
|
+
case PhysicalType::BOOL:
|
589
|
+
result.value_.boolean = deserializer.ReadProperty<bool>(101, "value");
|
590
|
+
break;
|
591
|
+
case PhysicalType::INT8:
|
592
|
+
result.value_.tinyint = deserializer.ReadProperty<int8_t>(101, "value");
|
593
|
+
break;
|
594
|
+
case PhysicalType::INT16:
|
595
|
+
result.value_.smallint = deserializer.ReadProperty<int16_t>(101, "value");
|
596
|
+
break;
|
597
|
+
case PhysicalType::INT32:
|
598
|
+
result.value_.integer = deserializer.ReadProperty<int32_t>(101, "value");
|
599
|
+
break;
|
600
|
+
case PhysicalType::INT64:
|
601
|
+
result.value_.bigint = deserializer.ReadProperty<int64_t>(101, "value");
|
602
|
+
break;
|
603
|
+
case PhysicalType::UINT8:
|
604
|
+
result.value_.utinyint = deserializer.ReadProperty<uint8_t>(101, "value");
|
605
|
+
break;
|
606
|
+
case PhysicalType::UINT16:
|
607
|
+
result.value_.usmallint = deserializer.ReadProperty<uint16_t>(101, "value");
|
608
|
+
break;
|
609
|
+
case PhysicalType::UINT32:
|
610
|
+
result.value_.uinteger = deserializer.ReadProperty<uint32_t>(101, "value");
|
611
|
+
break;
|
612
|
+
case PhysicalType::UINT64:
|
613
|
+
result.value_.ubigint = deserializer.ReadProperty<uint64_t>(101, "value");
|
614
|
+
break;
|
615
|
+
case PhysicalType::INT128:
|
616
|
+
result.value_.hugeint = deserializer.ReadProperty<hugeint_t>(101, "value");
|
617
|
+
break;
|
618
|
+
case PhysicalType::FLOAT:
|
619
|
+
result.value_.float_ = deserializer.ReadProperty<float>(101, "value");
|
620
|
+
break;
|
621
|
+
case PhysicalType::DOUBLE:
|
622
|
+
result.value_.double_ = deserializer.ReadProperty<double>(101, "value");
|
623
|
+
break;
|
624
|
+
default:
|
625
|
+
throw InternalException("Unsupported type for serializing numeric statistics");
|
626
|
+
}
|
627
|
+
}
|
628
|
+
|
629
|
+
BaseStatistics NumericStats::FormatDeserialize(FormatDeserializer &deserializer, LogicalType type) {
|
630
|
+
BaseStatistics result(std::move(type));
|
631
|
+
auto &numeric_stats = NumericStats::GetDataUnsafe(result);
|
632
|
+
|
633
|
+
deserializer.ReadObject(200, "max", [&](FormatDeserializer &object) {
|
634
|
+
FormatDeserializeNumericStatsValue(result.GetType(), numeric_stats.min, numeric_stats.has_min, object);
|
635
|
+
});
|
636
|
+
deserializer.ReadObject(201, "min", [&](FormatDeserializer &object) {
|
637
|
+
FormatDeserializeNumericStatsValue(result.GetType(), numeric_stats.max, numeric_stats.has_max, object);
|
638
|
+
});
|
639
|
+
return result;
|
640
|
+
}
|
641
|
+
|
517
642
|
string NumericStats::ToString(const BaseStatistics &stats) {
|
518
643
|
return StringUtil::Format("[Min: %s, Max: %s]", NumericStats::MinOrNull(stats).ToString(),
|
519
644
|
NumericStats::MaxOrNull(stats).ToString());
|
@@ -7,6 +7,9 @@
|
|
7
7
|
#include "duckdb/storage/statistics/base_statistics.hpp"
|
8
8
|
#include "utf8proc_wrapper.hpp"
|
9
9
|
|
10
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
11
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
12
|
+
|
10
13
|
namespace duckdb {
|
11
14
|
|
12
15
|
BaseStatistics StringStats::CreateUnknown(LogicalType type) {
|
@@ -103,6 +106,15 @@ void StringStats::Serialize(const BaseStatistics &stats, FieldWriter &writer) {
|
|
103
106
|
writer.WriteField<uint32_t>(string_data.max_string_length);
|
104
107
|
}
|
105
108
|
|
109
|
+
void StringStats::FormatSerialize(const BaseStatistics &stats, FormatSerializer &serializer) {
|
110
|
+
auto &string_data = StringStats::GetDataUnsafe(stats);
|
111
|
+
serializer.WriteProperty(200, "min", string_data.min, StringStatsData::MAX_STRING_MINMAX_SIZE);
|
112
|
+
serializer.WriteProperty(201, "max", string_data.max, StringStatsData::MAX_STRING_MINMAX_SIZE);
|
113
|
+
serializer.WriteProperty(202, "has_unicode", string_data.has_unicode);
|
114
|
+
serializer.WriteProperty(203, "has_max_string_length", string_data.has_max_string_length);
|
115
|
+
serializer.WriteProperty(204, "max_string_length", string_data.max_string_length);
|
116
|
+
}
|
117
|
+
|
106
118
|
BaseStatistics StringStats::Deserialize(FieldReader &reader, LogicalType type) {
|
107
119
|
BaseStatistics result(std::move(type));
|
108
120
|
auto &string_data = StringStats::GetDataUnsafe(result);
|
@@ -114,6 +126,17 @@ BaseStatistics StringStats::Deserialize(FieldReader &reader, LogicalType type) {
|
|
114
126
|
return result;
|
115
127
|
}
|
116
128
|
|
129
|
+
BaseStatistics StringStats::FormatDeserialize(FormatDeserializer &deserializer, LogicalType type) {
|
130
|
+
BaseStatistics result(std::move(type));
|
131
|
+
auto &string_data = StringStats::GetDataUnsafe(result);
|
132
|
+
deserializer.ReadProperty(200, "min", string_data.min, StringStatsData::MAX_STRING_MINMAX_SIZE);
|
133
|
+
deserializer.ReadProperty(201, "max", string_data.max, StringStatsData::MAX_STRING_MINMAX_SIZE);
|
134
|
+
deserializer.ReadProperty(202, "has_unicode", string_data.has_unicode);
|
135
|
+
deserializer.ReadProperty(203, "has_max_string_length", string_data.has_max_string_length);
|
136
|
+
deserializer.ReadProperty(204, "max_string_length", string_data.max_string_length);
|
137
|
+
return result;
|
138
|
+
}
|
139
|
+
|
117
140
|
static int StringValueComparison(const_data_ptr_t data, idx_t len, const_data_ptr_t comparison) {
|
118
141
|
D_ASSERT(len <= StringStatsData::MAX_STRING_MINMAX_SIZE);
|
119
142
|
for (idx_t i = 0; i < len; i++) {
|
@@ -3,6 +3,9 @@
|
|
3
3
|
#include "duckdb/common/field_writer.hpp"
|
4
4
|
#include "duckdb/common/types/vector.hpp"
|
5
5
|
|
6
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
7
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
8
|
+
|
6
9
|
namespace duckdb {
|
7
10
|
|
8
11
|
void StructStats::Construct(BaseStatistics &stats) {
|
@@ -109,6 +112,30 @@ BaseStatistics StructStats::Deserialize(FieldReader &reader, LogicalType type) {
|
|
109
112
|
return result;
|
110
113
|
}
|
111
114
|
|
115
|
+
void StructStats::FormatSerialize(const BaseStatistics &stats, FormatSerializer &serializer) {
|
116
|
+
auto child_stats = StructStats::GetChildStats(stats);
|
117
|
+
auto child_count = StructType::GetChildCount(stats.GetType());
|
118
|
+
|
119
|
+
serializer.WriteList(200, "child_stats", child_count,
|
120
|
+
[&](FormatSerializer::List &list, idx_t i) { list.WriteElement(child_stats[i]); });
|
121
|
+
}
|
122
|
+
|
123
|
+
BaseStatistics StructStats::FormatDeserialize(FormatDeserializer &deserializer, LogicalType type) {
|
124
|
+
D_ASSERT(type.InternalType() == PhysicalType::STRUCT);
|
125
|
+
|
126
|
+
auto &child_types = StructType::GetChildTypes(type);
|
127
|
+
BaseStatistics result(std::move(type));
|
128
|
+
|
129
|
+
deserializer.ReadList(200, "child_stats", [&](FormatDeserializer::List &list, idx_t i) {
|
130
|
+
deserializer.Set<LogicalType &>(const_cast<LogicalType &>(child_types[i].second));
|
131
|
+
auto stat = list.ReadElement<BaseStatistics>();
|
132
|
+
result.child_stats[i].Copy(stat);
|
133
|
+
deserializer.Unset<LogicalType>();
|
134
|
+
});
|
135
|
+
|
136
|
+
return result;
|
137
|
+
}
|
138
|
+
|
112
139
|
string StructStats::ToString(const BaseStatistics &stats) {
|
113
140
|
string result;
|
114
141
|
result += " {";
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#include "duckdb/storage/table/chunk_info.hpp"
|
2
2
|
#include "duckdb/transaction/transaction.hpp"
|
3
3
|
#include "duckdb/common/serializer.hpp"
|
4
|
+
#include "duckdb/common/serializer/format_serializer.hpp"
|
5
|
+
#include "duckdb/common/serializer/format_deserializer.hpp"
|
4
6
|
|
5
7
|
namespace duckdb {
|
6
8
|
|
@@ -42,6 +44,20 @@ unique_ptr<ChunkInfo> ChunkInfo::Deserialize(Deserializer &source) {
|
|
42
44
|
}
|
43
45
|
}
|
44
46
|
|
47
|
+
unique_ptr<ChunkInfo> ChunkInfo::FormatDeserialize(FormatDeserializer &deserializer) {
|
48
|
+
auto type = deserializer.ReadProperty<ChunkInfoType>(100, "type");
|
49
|
+
switch (type) {
|
50
|
+
case ChunkInfoType::EMPTY_INFO:
|
51
|
+
return nullptr;
|
52
|
+
case ChunkInfoType::CONSTANT_INFO:
|
53
|
+
return ChunkConstantInfo::FormatDeserialize(deserializer);
|
54
|
+
case ChunkInfoType::VECTOR_INFO:
|
55
|
+
return ChunkVectorInfo::FormatDeserialize(deserializer);
|
56
|
+
default:
|
57
|
+
throw SerializationException("Could not deserialize Chunk Info Type: unrecognized type");
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
45
61
|
//===--------------------------------------------------------------------===//
|
46
62
|
// Constant info
|
47
63
|
//===--------------------------------------------------------------------===//
|
@@ -51,7 +67,7 @@ ChunkConstantInfo::ChunkConstantInfo(idx_t start)
|
|
51
67
|
|
52
68
|
template <class OP>
|
53
69
|
idx_t ChunkConstantInfo::TemplatedGetSelVector(transaction_t start_time, transaction_t transaction_id,
|
54
|
-
SelectionVector &sel_vector, idx_t max_count) {
|
70
|
+
SelectionVector &sel_vector, idx_t max_count) const {
|
55
71
|
if (OP::UseInsertedVersion(start_time, transaction_id, insert_id) &&
|
56
72
|
OP::UseDeletedVersion(start_time, transaction_id, delete_id)) {
|
57
73
|
return max_count;
|
@@ -102,6 +118,24 @@ unique_ptr<ChunkInfo> ChunkConstantInfo::Deserialize(Deserializer &source) {
|
|
102
118
|
return std::move(info);
|
103
119
|
}
|
104
120
|
|
121
|
+
void ChunkConstantInfo::FormatSerialize(FormatSerializer &serializer) const {
|
122
|
+
bool is_deleted = insert_id >= TRANSACTION_ID_START || delete_id < TRANSACTION_ID_START;
|
123
|
+
if (!is_deleted) {
|
124
|
+
serializer.WriteProperty(100, "type", ChunkInfoType::EMPTY_INFO);
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
serializer.WriteProperty(100, "type", type);
|
128
|
+
serializer.WriteProperty(200, "start", start);
|
129
|
+
}
|
130
|
+
|
131
|
+
unique_ptr<ChunkInfo> ChunkConstantInfo::FormatDeserialize(FormatDeserializer &deserializer) {
|
132
|
+
auto start = deserializer.ReadProperty<idx_t>(200, "start");
|
133
|
+
auto info = make_uniq<ChunkConstantInfo>(start);
|
134
|
+
info->insert_id = 0;
|
135
|
+
info->delete_id = 0;
|
136
|
+
return std::move(info);
|
137
|
+
}
|
138
|
+
|
105
139
|
//===--------------------------------------------------------------------===//
|
106
140
|
// Vector info
|
107
141
|
//===--------------------------------------------------------------------===//
|
@@ -115,7 +149,7 @@ ChunkVectorInfo::ChunkVectorInfo(idx_t start)
|
|
115
149
|
|
116
150
|
template <class OP>
|
117
151
|
idx_t ChunkVectorInfo::TemplatedGetSelVector(transaction_t start_time, transaction_t transaction_id,
|
118
|
-
SelectionVector &sel_vector, idx_t max_count) {
|
152
|
+
SelectionVector &sel_vector, idx_t max_count) const {
|
119
153
|
idx_t count = 0;
|
120
154
|
if (same_inserted_id && !any_deleted) {
|
121
155
|
// all tuples have the same inserted id: and no tuples were deleted
|
@@ -154,7 +188,7 @@ idx_t ChunkVectorInfo::TemplatedGetSelVector(transaction_t start_time, transacti
|
|
154
188
|
}
|
155
189
|
|
156
190
|
idx_t ChunkVectorInfo::GetSelVector(transaction_t start_time, transaction_t transaction_id, SelectionVector &sel_vector,
|
157
|
-
idx_t max_count) {
|
191
|
+
idx_t max_count) const {
|
158
192
|
return TemplatedGetSelVector<TransactionVersionOperator>(start_time, transaction_id, sel_vector, max_count);
|
159
193
|
}
|
160
194
|
|
@@ -276,4 +310,49 @@ unique_ptr<ChunkInfo> ChunkVectorInfo::Deserialize(Deserializer &source) {
|
|
276
310
|
return std::move(result);
|
277
311
|
}
|
278
312
|
|
313
|
+
void ChunkVectorInfo::FormatSerialize(FormatSerializer &serializer) const {
|
314
|
+
SelectionVector sel(STANDARD_VECTOR_SIZE);
|
315
|
+
transaction_t start_time = TRANSACTION_ID_START - 1;
|
316
|
+
transaction_t transaction_id = DConstants::INVALID_INDEX;
|
317
|
+
idx_t count = GetSelVector(start_time, transaction_id, sel, STANDARD_VECTOR_SIZE);
|
318
|
+
if (count == STANDARD_VECTOR_SIZE) {
|
319
|
+
// nothing is deleted: skip writing anything
|
320
|
+
serializer.WriteProperty(100, "type", ChunkInfoType::EMPTY_INFO);
|
321
|
+
return;
|
322
|
+
}
|
323
|
+
if (count == 0) {
|
324
|
+
// everything is deleted: write a constant vector
|
325
|
+
serializer.WriteProperty(100, "type", ChunkInfoType::CONSTANT_INFO);
|
326
|
+
serializer.WriteProperty(200, "start", start);
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
// write a boolean vector
|
330
|
+
serializer.WriteProperty(100, "type", ChunkInfoType::VECTOR_INFO);
|
331
|
+
serializer.WriteProperty(200, "start", start);
|
332
|
+
bool deleted_tuples[STANDARD_VECTOR_SIZE];
|
333
|
+
for (idx_t i = 0; i < STANDARD_VECTOR_SIZE; i++) {
|
334
|
+
deleted_tuples[i] = true;
|
335
|
+
}
|
336
|
+
for (idx_t i = 0; i < count; i++) {
|
337
|
+
deleted_tuples[sel.get_index(i)] = false;
|
338
|
+
}
|
339
|
+
serializer.WriteProperty(201, "deleted_tuples", data_ptr_cast(deleted_tuples), sizeof(bool) * STANDARD_VECTOR_SIZE);
|
340
|
+
}
|
341
|
+
|
342
|
+
unique_ptr<ChunkInfo> ChunkVectorInfo::FormatDeserialize(FormatDeserializer &deserializer) {
|
343
|
+
auto start = deserializer.ReadProperty<idx_t>(200, "start");
|
344
|
+
|
345
|
+
auto result = make_uniq<ChunkVectorInfo>(start);
|
346
|
+
result->any_deleted = true;
|
347
|
+
bool deleted_tuples[STANDARD_VECTOR_SIZE];
|
348
|
+
deserializer.ReadProperty(201, "deleted_tuples", data_ptr_cast(deleted_tuples),
|
349
|
+
sizeof(bool) * STANDARD_VECTOR_SIZE);
|
350
|
+
for (idx_t i = 0; i < STANDARD_VECTOR_SIZE; i++) {
|
351
|
+
if (deleted_tuples[i]) {
|
352
|
+
result->deleted[i] = 0;
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return std::move(result);
|
356
|
+
}
|
357
|
+
|
279
358
|
} // namespace duckdb
|