duckdb 0.7.2-dev2820.0 → 0.7.2-dev2995.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 +1 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +55 -1
- package/src/duckdb/extension/parquet/parquet-extension.cpp +5 -4
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
- package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
- package/src/duckdb/src/common/local_file_system.cpp +1 -3
- package/src/duckdb/src/common/multi_file_reader.cpp +11 -8
- package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
- package/src/duckdb/src/common/string_util.cpp +6 -1
- package/src/duckdb/src/core_functions/function_list.cpp +2 -0
- package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
- package/src/duckdb/src/execution/index/art/art.cpp +5 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +62 -43
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
- package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
- package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +10 -8
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +10 -25
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
- package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
- package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -18
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -28
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
- package/src/duckdb/src/execution/physical_operator.cpp +11 -5
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
- package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
- package/src/duckdb/src/function/table/read_csv.cpp +7 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
- package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -4
- package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
- package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -8
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -5
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +6 -5
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +5 -5
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
- package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
- package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
- package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
- package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
- package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
- package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +5 -0
- package/src/duckdb/src/main/attached_database.cpp +5 -3
- package/src/duckdb/src/main/client_verify.cpp +4 -0
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +45 -48
- package/src/duckdb/src/main/extension/extension_load.cpp +32 -49
- package/src/duckdb/src/parallel/event.cpp +1 -1
- package/src/duckdb/src/parallel/executor.cpp +39 -3
- package/src/duckdb/src/parallel/executor_task.cpp +11 -0
- package/src/duckdb/src/parallel/interrupt.cpp +57 -0
- package/src/duckdb/src/parallel/pipeline.cpp +49 -6
- package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
- package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
- package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
- package/src/duckdb/src/parser/base_expression.cpp +6 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -4
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +43 -24
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -28
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -1
- package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
- package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
- package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
- package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
- package/src/duckdb/src/storage/data_table.cpp +5 -0
- package/src/duckdb/src/storage/local_storage.cpp +40 -110
- package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
- package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
- package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
- package/src/duckdb/src/storage/table/column_data.cpp +19 -45
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
- package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
- package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
- package/src/duckdb/src/storage/table/row_group.cpp +13 -14
- package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
- package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
- package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
- package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
- package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
- package/src/duckdb/src/transaction/commit_state.cpp +4 -4
- package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
- package/src/duckdb/src/verification/statement_verifier.cpp +4 -0
- package/src/duckdb/third_party/fmt/format.cc +0 -5
- package/src/duckdb/third_party/fmt/include/fmt/core.h +10 -12
- package/src/duckdb/third_party/fmt/include/fmt/format-inl.h +2 -33
- package/src/duckdb/third_party/fmt/include/fmt/format.h +61 -24
- package/src/duckdb/third_party/fmt/include/fmt/printf.h +15 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +10735 -10674
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_parallel.cpp +2 -0
- package/src/duckdb/ub_src_storage.cpp +2 -0
@@ -1,6 +1,8 @@
|
|
1
|
+
#include "duckdb/planner/operator/logical_insert.hpp"
|
2
|
+
|
1
3
|
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
|
2
4
|
#include "duckdb/common/field_writer.hpp"
|
3
|
-
#include "duckdb/
|
5
|
+
#include "duckdb/main/config.hpp"
|
4
6
|
#include "duckdb/parser/parsed_data/create_table_info.hpp"
|
5
7
|
|
6
8
|
namespace duckdb {
|
@@ -78,4 +80,13 @@ void LogicalInsert::ResolveTypes() {
|
|
78
80
|
}
|
79
81
|
}
|
80
82
|
|
83
|
+
string LogicalInsert::GetName() const {
|
84
|
+
#ifdef DEBUG
|
85
|
+
if (DBConfigOptions::debug_print_bindings) {
|
86
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index);
|
87
|
+
}
|
88
|
+
#endif
|
89
|
+
return LogicalOperator::GetName();
|
90
|
+
}
|
91
|
+
|
81
92
|
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/planner/operator/logical_pivot.hpp"
|
2
2
|
|
3
|
+
#include "duckdb/main/config.hpp"
|
4
|
+
|
3
5
|
namespace duckdb {
|
4
6
|
|
5
7
|
LogicalPivot::LogicalPivot(idx_t pivot_idx, unique_ptr<LogicalOperator> plan, BoundPivotInfo info_p)
|
@@ -32,4 +34,13 @@ void LogicalPivot::ResolveTypes() {
|
|
32
34
|
this->types = bound_pivot.types;
|
33
35
|
}
|
34
36
|
|
37
|
+
string LogicalPivot::GetName() const {
|
38
|
+
#ifdef DEBUG
|
39
|
+
if (DBConfigOptions::debug_print_bindings) {
|
40
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", pivot_index);
|
41
|
+
}
|
42
|
+
#endif
|
43
|
+
return LogicalOperator::GetName();
|
44
|
+
}
|
45
|
+
|
35
46
|
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/planner/operator/logical_projection.hpp"
|
2
|
+
|
2
3
|
#include "duckdb/common/field_writer.hpp"
|
4
|
+
#include "duckdb/main/config.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -32,4 +34,13 @@ vector<idx_t> LogicalProjection::GetTableIndex() const {
|
|
32
34
|
return vector<idx_t> {table_index};
|
33
35
|
}
|
34
36
|
|
37
|
+
string LogicalProjection::GetName() const {
|
38
|
+
#ifdef DEBUG
|
39
|
+
if (DBConfigOptions::debug_print_bindings) {
|
40
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index);
|
41
|
+
}
|
42
|
+
#endif
|
43
|
+
return LogicalOperator::GetName();
|
44
|
+
}
|
45
|
+
|
35
46
|
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/planner/operator/logical_recursive_cte.hpp"
|
2
|
+
|
2
3
|
#include "duckdb/common/field_writer.hpp"
|
4
|
+
#include "duckdb/main/config.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -21,4 +23,13 @@ vector<idx_t> LogicalRecursiveCTE::GetTableIndex() const {
|
|
21
23
|
return vector<idx_t> {table_index};
|
22
24
|
}
|
23
25
|
|
26
|
+
string LogicalRecursiveCTE::GetName() const {
|
27
|
+
#ifdef DEBUG
|
28
|
+
if (DBConfigOptions::debug_print_bindings) {
|
29
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index);
|
30
|
+
}
|
31
|
+
#endif
|
32
|
+
return LogicalOperator::GetName();
|
33
|
+
}
|
34
|
+
|
24
35
|
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/planner/operator/logical_set_operation.hpp"
|
2
|
+
|
2
3
|
#include "duckdb/common/field_writer.hpp"
|
4
|
+
#include "duckdb/main/config.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -19,4 +21,13 @@ vector<idx_t> LogicalSetOperation::GetTableIndex() const {
|
|
19
21
|
return vector<idx_t> {table_index};
|
20
22
|
}
|
21
23
|
|
24
|
+
string LogicalSetOperation::GetName() const {
|
25
|
+
#ifdef DEBUG
|
26
|
+
if (DBConfigOptions::debug_print_bindings) {
|
27
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index);
|
28
|
+
}
|
29
|
+
#endif
|
30
|
+
return LogicalOperator::GetName();
|
31
|
+
}
|
32
|
+
|
22
33
|
} // namespace duckdb
|
@@ -1,6 +1,8 @@
|
|
1
|
-
#include "duckdb/common/field_writer.hpp"
|
2
1
|
#include "duckdb/planner/operator/logical_unnest.hpp"
|
3
2
|
|
3
|
+
#include "duckdb/common/field_writer.hpp"
|
4
|
+
#include "duckdb/main/config.hpp"
|
5
|
+
|
4
6
|
namespace duckdb {
|
5
7
|
|
6
8
|
vector<ColumnBinding> LogicalUnnest::GetColumnBindings() {
|
@@ -35,4 +37,13 @@ vector<idx_t> LogicalUnnest::GetTableIndex() const {
|
|
35
37
|
return vector<idx_t> {unnest_index};
|
36
38
|
}
|
37
39
|
|
40
|
+
string LogicalUnnest::GetName() const {
|
41
|
+
#ifdef DEBUG
|
42
|
+
if (DBConfigOptions::debug_print_bindings) {
|
43
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", unnest_index);
|
44
|
+
}
|
45
|
+
#endif
|
46
|
+
return LogicalOperator::GetName();
|
47
|
+
}
|
48
|
+
|
38
49
|
} // namespace duckdb
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include "duckdb/common/field_writer.hpp"
|
3
3
|
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
|
4
4
|
#include "duckdb/parser/parsed_data/create_table_info.hpp"
|
5
|
+
#include "duckdb/main/config.hpp"
|
5
6
|
|
6
7
|
namespace duckdb {
|
7
8
|
|
@@ -52,4 +53,13 @@ void LogicalUpdate::ResolveTypes() {
|
|
52
53
|
}
|
53
54
|
}
|
54
55
|
|
56
|
+
string LogicalUpdate::GetName() const {
|
57
|
+
#ifdef DEBUG
|
58
|
+
if (DBConfigOptions::debug_print_bindings) {
|
59
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", table_index);
|
60
|
+
}
|
61
|
+
#endif
|
62
|
+
return LogicalOperator::GetName();
|
63
|
+
}
|
64
|
+
|
55
65
|
} // namespace duckdb
|
@@ -1,5 +1,7 @@
|
|
1
1
|
#include "duckdb/planner/operator/logical_window.hpp"
|
2
|
+
|
2
3
|
#include "duckdb/common/field_writer.hpp"
|
4
|
+
#include "duckdb/main/config.hpp"
|
3
5
|
|
4
6
|
namespace duckdb {
|
5
7
|
|
@@ -34,4 +36,13 @@ vector<idx_t> LogicalWindow::GetTableIndex() const {
|
|
34
36
|
return vector<idx_t> {window_index};
|
35
37
|
}
|
36
38
|
|
39
|
+
string LogicalWindow::GetName() const {
|
40
|
+
#ifdef DEBUG
|
41
|
+
if (DBConfigOptions::debug_print_bindings) {
|
42
|
+
return LogicalOperator::GetName() + StringUtil::Format(" #%llu", window_index);
|
43
|
+
}
|
44
|
+
#endif
|
45
|
+
return LogicalOperator::GetName();
|
46
|
+
}
|
47
|
+
|
37
48
|
} // namespace duckdb
|
@@ -37,7 +37,7 @@ namespace duckdb {
|
|
37
37
|
void ReorderTableEntries(vector<reference<TableCatalogEntry>> &tables);
|
38
38
|
|
39
39
|
SingleFileCheckpointWriter::SingleFileCheckpointWriter(AttachedDatabase &db, BlockManager &block_manager)
|
40
|
-
: CheckpointWriter(db), partial_block_manager(block_manager) {
|
40
|
+
: CheckpointWriter(db), partial_block_manager(block_manager, CheckpointType::FULL_CHECKPOINT) {
|
41
41
|
}
|
42
42
|
|
43
43
|
BlockManager &SingleFileCheckpointWriter::GetBlockManager() {
|
@@ -665,6 +665,11 @@ OptimisticDataWriter &DataTable::CreateOptimisticWriter(ClientContext &context)
|
|
665
665
|
return local_storage.CreateOptimisticWriter(*this);
|
666
666
|
}
|
667
667
|
|
668
|
+
void DataTable::FinalizeOptimisticWriter(ClientContext &context, OptimisticDataWriter &writer) {
|
669
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
670
|
+
local_storage.FinalizeOptimisticWriter(*this, writer);
|
671
|
+
}
|
672
|
+
|
668
673
|
void DataTable::LocalMerge(ClientContext &context, RowGroupCollection &collection) {
|
669
674
|
auto &local_storage = LocalStorage::Get(context, db);
|
670
675
|
local_storage.LocalMerge(*this, collection);
|
@@ -9,111 +9,14 @@
|
|
9
9
|
#include "duckdb/storage/partial_block_manager.hpp"
|
10
10
|
|
11
11
|
#include "duckdb/storage/table/column_checkpoint_state.hpp"
|
12
|
-
#include "duckdb/storage/table/column_segment.hpp"
|
13
12
|
#include "duckdb/storage/table_io_manager.hpp"
|
14
13
|
#include "duckdb/storage/table/scan_state.hpp"
|
15
14
|
|
16
15
|
namespace duckdb {
|
17
16
|
|
18
|
-
//===--------------------------------------------------------------------===//
|
19
|
-
// OptimisticDataWriter
|
20
|
-
//===--------------------------------------------------------------------===//
|
21
|
-
OptimisticDataWriter::OptimisticDataWriter(DataTable &table) : table(table) {
|
22
|
-
}
|
23
|
-
|
24
|
-
OptimisticDataWriter::OptimisticDataWriter(DataTable &table, OptimisticDataWriter &parent)
|
25
|
-
: table(table), partial_manager(std::move(parent.partial_manager)),
|
26
|
-
written_blocks(std::move(parent.written_blocks)) {
|
27
|
-
if (partial_manager) {
|
28
|
-
partial_manager->FlushPartialBlocks();
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
OptimisticDataWriter::~OptimisticDataWriter() {
|
33
|
-
}
|
34
|
-
|
35
|
-
bool OptimisticDataWriter::PrepareWrite() {
|
36
|
-
// check if we should pre-emptively write the table to disk
|
37
|
-
if (table.info->IsTemporary() || StorageManager::Get(table.info->db).InMemory()) {
|
38
|
-
return false;
|
39
|
-
}
|
40
|
-
// we should! write the second-to-last row group to disk
|
41
|
-
// allocate the partial block-manager if none is allocated yet
|
42
|
-
if (!partial_manager) {
|
43
|
-
auto &block_manager = table.info->table_io_manager->GetBlockManagerForRowData();
|
44
|
-
partial_manager = make_uniq<PartialBlockManager>(block_manager);
|
45
|
-
}
|
46
|
-
return true;
|
47
|
-
}
|
48
|
-
|
49
|
-
void OptimisticDataWriter::CheckFlushToDisk(RowGroupCollection &row_groups) {
|
50
|
-
// we finished writing a complete row group
|
51
|
-
if (!PrepareWrite()) {
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
// flush second-to-last row group
|
55
|
-
auto row_group = row_groups.GetRowGroup(-2);
|
56
|
-
FlushToDisk(row_group);
|
57
|
-
}
|
58
|
-
|
59
|
-
void OptimisticDataWriter::FlushToDisk(RowGroup *row_group) {
|
60
|
-
// flush the specified row group
|
61
|
-
D_ASSERT(row_group);
|
62
|
-
//! The set of column compression types (if any)
|
63
|
-
vector<CompressionType> compression_types;
|
64
|
-
D_ASSERT(compression_types.empty());
|
65
|
-
for (auto &column : table.column_definitions) {
|
66
|
-
compression_types.push_back(column.CompressionType());
|
67
|
-
}
|
68
|
-
auto row_group_pointer = row_group->WriteToDisk(*partial_manager, compression_types);
|
69
|
-
|
70
|
-
// update the set of written blocks
|
71
|
-
for (idx_t col_idx = 0; col_idx < row_group_pointer.statistics.size(); col_idx++) {
|
72
|
-
row_group_pointer.states[col_idx]->GetBlockIds(written_blocks);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
void OptimisticDataWriter::FlushToDisk(RowGroupCollection &row_groups, bool force) {
|
77
|
-
if (!partial_manager) {
|
78
|
-
if (!force) {
|
79
|
-
// no partial manager - nothing to flush
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
if (!PrepareWrite()) {
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
// flush the last row group
|
87
|
-
FlushToDisk(row_groups.GetRowGroup(-1));
|
88
|
-
}
|
89
|
-
|
90
|
-
void OptimisticDataWriter::FinalFlush() {
|
91
|
-
if (!partial_manager) {
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
// then flush the partial manager
|
95
|
-
partial_manager->FlushPartialBlocks();
|
96
|
-
partial_manager.reset();
|
97
|
-
}
|
98
|
-
|
99
|
-
void OptimisticDataWriter::Rollback() {
|
100
|
-
if (partial_manager) {
|
101
|
-
partial_manager->Clear();
|
102
|
-
partial_manager.reset();
|
103
|
-
}
|
104
|
-
if (!written_blocks.empty()) {
|
105
|
-
auto &block_manager = table.info->table_io_manager->GetBlockManagerForRowData();
|
106
|
-
for (auto block_id : written_blocks) {
|
107
|
-
block_manager.MarkBlockAsFree(block_id);
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
//===--------------------------------------------------------------------===//
|
113
|
-
// Local Table Storage
|
114
|
-
//===--------------------------------------------------------------------===//
|
115
17
|
LocalTableStorage::LocalTableStorage(DataTable &table)
|
116
|
-
: table_ref(table), allocator(Allocator::Get(table.db)), deleted_rows(0), optimistic_writer(table)
|
18
|
+
: table_ref(table), allocator(Allocator::Get(table.db)), deleted_rows(0), optimistic_writer(table),
|
19
|
+
merged_storage(false) {
|
117
20
|
auto types = table.GetTypes();
|
118
21
|
row_groups = make_shared<RowGroupCollection>(table.info, TableIOManager::Get(table).GetBlockManagerForRowData(),
|
119
22
|
types, MAX_ROW_ID, 0);
|
@@ -140,7 +43,8 @@ LocalTableStorage::LocalTableStorage(ClientContext &context, DataTable &new_dt,
|
|
140
43
|
idx_t changed_idx, const LogicalType &target_type,
|
141
44
|
const vector<column_t> &bound_columns, Expression &cast_expr)
|
142
45
|
: table_ref(new_dt), allocator(Allocator::Get(new_dt.db)), deleted_rows(parent.deleted_rows),
|
143
|
-
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers))
|
46
|
+
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers)),
|
47
|
+
merged_storage(parent.merged_storage) {
|
144
48
|
row_groups = parent.row_groups->AlterType(context, changed_idx, target_type, bound_columns, cast_expr);
|
145
49
|
parent.row_groups.reset();
|
146
50
|
indexes.Move(parent.indexes);
|
@@ -148,7 +52,8 @@ LocalTableStorage::LocalTableStorage(ClientContext &context, DataTable &new_dt,
|
|
148
52
|
|
149
53
|
LocalTableStorage::LocalTableStorage(DataTable &new_dt, LocalTableStorage &parent, idx_t drop_idx)
|
150
54
|
: table_ref(new_dt), allocator(Allocator::Get(new_dt.db)), deleted_rows(parent.deleted_rows),
|
151
|
-
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers))
|
55
|
+
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers)),
|
56
|
+
merged_storage(parent.merged_storage) {
|
152
57
|
row_groups = parent.row_groups->RemoveColumn(drop_idx);
|
153
58
|
parent.row_groups.reset();
|
154
59
|
indexes.Move(parent.indexes);
|
@@ -157,7 +62,8 @@ LocalTableStorage::LocalTableStorage(DataTable &new_dt, LocalTableStorage &paren
|
|
157
62
|
LocalTableStorage::LocalTableStorage(ClientContext &context, DataTable &new_dt, LocalTableStorage &parent,
|
158
63
|
ColumnDefinition &new_column, optional_ptr<Expression> default_value)
|
159
64
|
: table_ref(new_dt), allocator(Allocator::Get(new_dt.db)), deleted_rows(parent.deleted_rows),
|
160
|
-
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers))
|
65
|
+
optimistic_writer(new_dt, parent.optimistic_writer), optimistic_writers(std::move(parent.optimistic_writers)),
|
66
|
+
merged_storage(parent.merged_storage) {
|
161
67
|
row_groups = parent.row_groups->AddColumn(context, new_column, default_value.get());
|
162
68
|
parent.row_groups.reset();
|
163
69
|
indexes.Move(parent.indexes);
|
@@ -187,16 +93,18 @@ idx_t LocalTableStorage::EstimatedSize() {
|
|
187
93
|
return appended_rows * row_size;
|
188
94
|
}
|
189
95
|
|
190
|
-
void LocalTableStorage::
|
96
|
+
void LocalTableStorage::WriteNewRowGroup() {
|
191
97
|
if (deleted_rows != 0) {
|
192
98
|
// we have deletes - we cannot merge row groups
|
193
99
|
return;
|
194
100
|
}
|
195
|
-
optimistic_writer.
|
101
|
+
optimistic_writer.WriteNewRowGroup(*row_groups);
|
196
102
|
}
|
197
103
|
|
198
|
-
void LocalTableStorage::
|
199
|
-
|
104
|
+
void LocalTableStorage::FlushBlocks() {
|
105
|
+
if (!merged_storage && row_groups->GetTotalRows() > RowGroup::ROW_GROUP_SIZE) {
|
106
|
+
optimistic_writer.WriteLastRowGroup(*row_groups);
|
107
|
+
}
|
200
108
|
optimistic_writer.FinalFlush();
|
201
109
|
}
|
202
110
|
|
@@ -286,12 +194,28 @@ OptimisticDataWriter &LocalTableStorage::CreateOptimisticWriter() {
|
|
286
194
|
return *optimistic_writers.back();
|
287
195
|
}
|
288
196
|
|
197
|
+
void LocalTableStorage::FinalizeOptimisticWriter(OptimisticDataWriter &writer) {
|
198
|
+
// remove the writer from the set of optimistic writers
|
199
|
+
unique_ptr<OptimisticDataWriter> owned_writer;
|
200
|
+
for (idx_t i = 0; i < optimistic_writers.size(); i++) {
|
201
|
+
if (optimistic_writers[i].get() == &writer) {
|
202
|
+
owned_writer = std::move(optimistic_writers[i]);
|
203
|
+
optimistic_writers.erase(optimistic_writers.begin() + i);
|
204
|
+
break;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
if (!owned_writer) {
|
208
|
+
throw InternalException("Error in FinalizeOptimisticWriter - could not find writer");
|
209
|
+
}
|
210
|
+
optimistic_writer.Merge(*owned_writer);
|
211
|
+
}
|
212
|
+
|
289
213
|
void LocalTableStorage::Rollback() {
|
290
|
-
optimistic_writer.Rollback();
|
291
214
|
for (auto &writer : optimistic_writers) {
|
292
215
|
writer->Rollback();
|
293
216
|
}
|
294
217
|
optimistic_writers.clear();
|
218
|
+
optimistic_writer.Rollback();
|
295
219
|
}
|
296
220
|
|
297
221
|
//===--------------------------------------------------------------------===//
|
@@ -429,7 +353,7 @@ void LocalStorage::Append(LocalAppendState &state, DataChunk &chunk) {
|
|
429
353
|
|
430
354
|
//! Check if we should pre-emptively flush blocks to disk
|
431
355
|
if (new_row_group) {
|
432
|
-
storage->
|
356
|
+
storage->WriteNewRowGroup();
|
433
357
|
}
|
434
358
|
}
|
435
359
|
|
@@ -448,6 +372,7 @@ void LocalStorage::LocalMerge(DataTable &table, RowGroupCollection &collection)
|
|
448
372
|
}
|
449
373
|
}
|
450
374
|
storage.row_groups->MergeStorage(collection);
|
375
|
+
storage.merged_storage = true;
|
451
376
|
}
|
452
377
|
|
453
378
|
OptimisticDataWriter &LocalStorage::CreateOptimisticWriter(DataTable &table) {
|
@@ -455,6 +380,11 @@ OptimisticDataWriter &LocalStorage::CreateOptimisticWriter(DataTable &table) {
|
|
455
380
|
return storage.CreateOptimisticWriter();
|
456
381
|
}
|
457
382
|
|
383
|
+
void LocalStorage::FinalizeOptimisticWriter(DataTable &table, OptimisticDataWriter &writer) {
|
384
|
+
auto &storage = table_manager.GetOrCreateStorage(table);
|
385
|
+
storage.FinalizeOptimisticWriter(writer);
|
386
|
+
}
|
387
|
+
|
458
388
|
bool LocalStorage::ChangesMade() noexcept {
|
459
389
|
return !table_manager.IsEmpty();
|
460
390
|
}
|
@@ -502,8 +432,8 @@ void LocalStorage::Flush(DataTable &table, LocalTableStorage &storage) {
|
|
502
432
|
if ((append_state.row_start == 0 || storage.row_groups->GetTotalRows() >= MERGE_THRESHOLD) &&
|
503
433
|
storage.deleted_rows == 0) {
|
504
434
|
// table is currently empty OR we are bulk appending: move over the storage directly
|
505
|
-
// first flush any
|
506
|
-
storage.
|
435
|
+
// first flush any outstanding blocks
|
436
|
+
storage.FlushBlocks();
|
507
437
|
// now append to the indexes (if there are any)
|
508
438
|
// FIXME: we should be able to merge the transaction-local index directly into the main table index
|
509
439
|
// as long we just rewrite some row-ids
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#include "duckdb/storage/optimistic_data_writer.hpp"
|
2
|
+
#include "duckdb/storage/table/column_segment.hpp"
|
3
|
+
#include "duckdb/storage/partial_block_manager.hpp"
|
4
|
+
#include "duckdb/storage/table/column_checkpoint_state.hpp"
|
5
|
+
|
6
|
+
namespace duckdb {
|
7
|
+
|
8
|
+
OptimisticDataWriter::OptimisticDataWriter(DataTable &table) : table(table) {
|
9
|
+
}
|
10
|
+
|
11
|
+
OptimisticDataWriter::OptimisticDataWriter(DataTable &table, OptimisticDataWriter &parent) : table(table) {
|
12
|
+
if (parent.partial_manager) {
|
13
|
+
parent.partial_manager->ClearBlocks();
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
OptimisticDataWriter::~OptimisticDataWriter() {
|
18
|
+
}
|
19
|
+
|
20
|
+
bool OptimisticDataWriter::PrepareWrite() {
|
21
|
+
// check if we should pre-emptively write the table to disk
|
22
|
+
if (table.info->IsTemporary() || StorageManager::Get(table.info->db).InMemory()) {
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
// we should! write the second-to-last row group to disk
|
26
|
+
// allocate the partial block-manager if none is allocated yet
|
27
|
+
if (!partial_manager) {
|
28
|
+
auto &block_manager = table.info->table_io_manager->GetBlockManagerForRowData();
|
29
|
+
partial_manager = make_uniq<PartialBlockManager>(block_manager, CheckpointType::APPEND_TO_TABLE);
|
30
|
+
}
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
|
34
|
+
void OptimisticDataWriter::WriteNewRowGroup(RowGroupCollection &row_groups) {
|
35
|
+
// we finished writing a complete row group
|
36
|
+
if (!PrepareWrite()) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
// flush second-to-last row group
|
40
|
+
auto row_group = row_groups.GetRowGroup(-2);
|
41
|
+
FlushToDisk(row_group);
|
42
|
+
}
|
43
|
+
|
44
|
+
void OptimisticDataWriter::WriteLastRowGroup(RowGroupCollection &row_groups) {
|
45
|
+
// we finished writing a complete row group
|
46
|
+
if (!PrepareWrite()) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
// flush second-to-last row group
|
50
|
+
auto row_group = row_groups.GetRowGroup(-1);
|
51
|
+
if (!row_group) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
FlushToDisk(row_group);
|
55
|
+
}
|
56
|
+
|
57
|
+
void OptimisticDataWriter::FlushToDisk(RowGroup *row_group) {
|
58
|
+
if (!row_group) {
|
59
|
+
throw InternalException("FlushToDisk called without a RowGroup");
|
60
|
+
}
|
61
|
+
//! The set of column compression types (if any)
|
62
|
+
vector<CompressionType> compression_types;
|
63
|
+
D_ASSERT(compression_types.empty());
|
64
|
+
for (auto &column : table.column_definitions) {
|
65
|
+
compression_types.push_back(column.CompressionType());
|
66
|
+
}
|
67
|
+
row_group->WriteToDisk(*partial_manager, compression_types);
|
68
|
+
}
|
69
|
+
|
70
|
+
void OptimisticDataWriter::Merge(OptimisticDataWriter &other) {
|
71
|
+
if (!other.partial_manager) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
if (!partial_manager) {
|
75
|
+
partial_manager = std::move(other.partial_manager);
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
partial_manager->Merge(*other.partial_manager);
|
79
|
+
other.partial_manager.reset();
|
80
|
+
}
|
81
|
+
|
82
|
+
void OptimisticDataWriter::FinalFlush() {
|
83
|
+
if (partial_manager) {
|
84
|
+
partial_manager->FlushPartialBlocks();
|
85
|
+
partial_manager.reset();
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
void OptimisticDataWriter::Rollback() {
|
90
|
+
if (partial_manager) {
|
91
|
+
partial_manager->Rollback();
|
92
|
+
partial_manager.reset();
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
} // namespace duckdb
|
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
namespace duckdb {
|
4
4
|
|
5
|
-
PartialBlockManager::PartialBlockManager(BlockManager &block_manager,
|
6
|
-
uint32_t max_use_count)
|
7
|
-
: block_manager(block_manager),
|
5
|
+
PartialBlockManager::PartialBlockManager(BlockManager &block_manager, CheckpointType checkpoint_type,
|
6
|
+
uint32_t max_partial_block_size, uint32_t max_use_count)
|
7
|
+
: block_manager(block_manager), checkpoint_type(checkpoint_type), max_partial_block_size(max_partial_block_size),
|
8
|
+
max_use_count(max_use_count) {
|
8
9
|
}
|
9
10
|
PartialBlockManager::~PartialBlockManager() {
|
10
11
|
}
|
@@ -23,7 +24,9 @@ PartialBlockAllocation PartialBlockManager::GetBlockAllocation(uint32_t segment_
|
|
23
24
|
//! there is! increase the reference count of this block
|
24
25
|
allocation.partial_block->state.block_use_count += 1;
|
25
26
|
allocation.state = allocation.partial_block->state;
|
26
|
-
|
27
|
+
if (checkpoint_type == CheckpointType::FULL_CHECKPOINT) {
|
28
|
+
block_manager.IncreaseBlockReferenceCount(allocation.state.block_id);
|
29
|
+
}
|
27
30
|
} else {
|
28
31
|
// full block: get a free block to write to
|
29
32
|
AllocateBlock(allocation.state, segment_size);
|
@@ -31,9 +34,18 @@ PartialBlockAllocation PartialBlockManager::GetBlockAllocation(uint32_t segment_
|
|
31
34
|
return allocation;
|
32
35
|
}
|
33
36
|
|
37
|
+
bool PartialBlockManager::HasBlockAllocation(uint32_t segment_size) {
|
38
|
+
return segment_size <= max_partial_block_size &&
|
39
|
+
partially_filled_blocks.lower_bound(segment_size) != partially_filled_blocks.end();
|
40
|
+
}
|
41
|
+
|
34
42
|
void PartialBlockManager::AllocateBlock(PartialBlockState &state, uint32_t segment_size) {
|
35
43
|
D_ASSERT(segment_size <= Storage::BLOCK_SIZE);
|
36
|
-
|
44
|
+
if (checkpoint_type == CheckpointType::FULL_CHECKPOINT) {
|
45
|
+
state.block_id = block_manager.GetFreeBlockId();
|
46
|
+
} else {
|
47
|
+
state.block_id = INVALID_BLOCK;
|
48
|
+
}
|
37
49
|
state.block_size = Storage::BLOCK_SIZE;
|
38
50
|
state.offset_in_block = 0;
|
39
51
|
state.block_use_count = 1;
|
@@ -82,21 +94,73 @@ void PartialBlockManager::RegisterPartialBlock(PartialBlockAllocation &&allocati
|
|
82
94
|
// Flush any block that we're not going to reuse.
|
83
95
|
if (block_to_free) {
|
84
96
|
block_to_free->Flush(free_space);
|
97
|
+
AddWrittenBlock(block_to_free->state.block_id);
|
85
98
|
}
|
86
99
|
}
|
87
100
|
|
88
|
-
void
|
101
|
+
void PartialBlock::Merge(PartialBlock &other, idx_t offset, idx_t other_size) {
|
102
|
+
throw InternalException("PartialBlock::Merge not implemented for this block type");
|
103
|
+
}
|
104
|
+
|
105
|
+
void PartialBlockManager::Merge(PartialBlockManager &other) {
|
106
|
+
if (&other == this) {
|
107
|
+
throw InternalException("Cannot merge into itself");
|
108
|
+
}
|
109
|
+
// for each partially filled block in the other manager, check if we can merge it into an existing block in this
|
110
|
+
// manager
|
111
|
+
for (auto &e : other.partially_filled_blocks) {
|
112
|
+
if (!e.second) {
|
113
|
+
throw InternalException("Empty partially filled block found");
|
114
|
+
}
|
115
|
+
auto used_space = Storage::BLOCK_SIZE - e.first;
|
116
|
+
if (HasBlockAllocation(used_space)) {
|
117
|
+
// we can merge this block into an existing block - merge them
|
118
|
+
// merge blocks
|
119
|
+
auto allocation = GetBlockAllocation(used_space);
|
120
|
+
allocation.partial_block->Merge(*e.second, allocation.state.offset_in_block, used_space);
|
121
|
+
|
122
|
+
// re-register the partial block
|
123
|
+
allocation.state.offset_in_block += used_space;
|
124
|
+
RegisterPartialBlock(std::move(allocation));
|
125
|
+
} else {
|
126
|
+
// we cannot merge this block - append it directly to the current block manager
|
127
|
+
partially_filled_blocks.insert(make_pair(e.first, std::move(e.second)));
|
128
|
+
}
|
129
|
+
}
|
130
|
+
// copy over the written blocks
|
131
|
+
for (auto &block_id : other.written_blocks) {
|
132
|
+
AddWrittenBlock(block_id);
|
133
|
+
}
|
134
|
+
other.written_blocks.clear();
|
135
|
+
other.partially_filled_blocks.clear();
|
136
|
+
}
|
137
|
+
|
138
|
+
void PartialBlockManager::AddWrittenBlock(block_id_t block) {
|
139
|
+
auto entry = written_blocks.insert(block);
|
140
|
+
if (!entry.second) {
|
141
|
+
throw InternalException("Written block already exists");
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
void PartialBlockManager::ClearBlocks() {
|
89
146
|
for (auto &e : partially_filled_blocks) {
|
90
|
-
e.second->
|
147
|
+
e.second->Clear();
|
91
148
|
}
|
92
149
|
partially_filled_blocks.clear();
|
93
150
|
}
|
94
151
|
|
95
|
-
void PartialBlockManager::
|
152
|
+
void PartialBlockManager::FlushPartialBlocks() {
|
96
153
|
for (auto &e : partially_filled_blocks) {
|
97
|
-
e.second->
|
154
|
+
e.second->Flush(e.first);
|
98
155
|
}
|
99
156
|
partially_filled_blocks.clear();
|
100
157
|
}
|
101
158
|
|
159
|
+
void PartialBlockManager::Rollback() {
|
160
|
+
ClearBlocks();
|
161
|
+
for (auto &block_id : written_blocks) {
|
162
|
+
block_manager.MarkBlockAsFree(block_id);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
102
166
|
} // namespace duckdb
|
@@ -287,7 +287,9 @@ void SingleFileBlockManager::MarkBlockAsFree(block_id_t block_id) {
|
|
287
287
|
lock_guard<mutex> lock(block_lock);
|
288
288
|
D_ASSERT(block_id >= 0);
|
289
289
|
D_ASSERT(block_id < max_block);
|
290
|
-
|
290
|
+
if (free_list.find(block_id) != free_list.end()) {
|
291
|
+
throw InternalException("MarkBlockAsFree called but block %llu was already freed!", block_id);
|
292
|
+
}
|
291
293
|
multi_use_blocks.erase(block_id);
|
292
294
|
free_list.insert(block_id);
|
293
295
|
}
|