duckdb 0.7.2-dev2867.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 +5 -1
- 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/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 +9 -26
- 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/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/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 +2 -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/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/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/client_verify.cpp +4 -0
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +11 -11
- package/src/duckdb/src/main/extension/extension_load.cpp +19 -15
- 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/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/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
@@ -28,9 +28,7 @@ public:
|
|
28
28
|
|
29
29
|
public:
|
30
30
|
// Source interface
|
31
|
-
|
32
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
33
|
-
LocalSourceState &lstate) const override;
|
31
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
34
32
|
|
35
33
|
bool IsSource() const override {
|
36
34
|
return true;
|
package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp
CHANGED
@@ -28,9 +28,7 @@ public:
|
|
28
28
|
|
29
29
|
public:
|
30
30
|
// Source interface
|
31
|
-
|
32
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
33
|
-
LocalSourceState &lstate) const override;
|
31
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
34
32
|
|
35
33
|
bool IsSource() const override {
|
36
34
|
return true;
|
@@ -29,9 +29,7 @@ public:
|
|
29
29
|
|
30
30
|
public:
|
31
31
|
// Source interface
|
32
|
-
|
33
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
34
|
-
LocalSourceState &lstate) const override;
|
32
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
35
33
|
|
36
34
|
bool IsSource() const override {
|
37
35
|
return true;
|
@@ -25,9 +25,7 @@ public:
|
|
25
25
|
|
26
26
|
public:
|
27
27
|
// Source interface
|
28
|
-
|
29
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
30
|
-
LocalSourceState &lstate) const override;
|
28
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
31
29
|
|
32
30
|
bool IsSource() const override {
|
33
31
|
return true;
|
@@ -37,8 +35,7 @@ public:
|
|
37
35
|
// Sink interface
|
38
36
|
unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
|
39
37
|
|
40
|
-
SinkResultType Sink(ExecutionContext &context,
|
41
|
-
DataChunk &input) const override;
|
38
|
+
SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override;
|
42
39
|
|
43
40
|
bool IsSink() const override {
|
44
41
|
return info->query != nullptr;
|
@@ -28,9 +28,7 @@ public:
|
|
28
28
|
|
29
29
|
public:
|
30
30
|
// Source interface
|
31
|
-
|
32
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
33
|
-
LocalSourceState &lstate) const override;
|
31
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
34
32
|
|
35
33
|
bool IsSource() const override {
|
36
34
|
return true;
|
@@ -27,9 +27,7 @@ public:
|
|
27
27
|
|
28
28
|
public:
|
29
29
|
// Source interface
|
30
|
-
|
31
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
32
|
-
LocalSourceState &lstate) const override;
|
30
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
33
31
|
|
34
32
|
bool IsSource() const override {
|
35
33
|
return true;
|
@@ -28,9 +28,7 @@ public:
|
|
28
28
|
|
29
29
|
public:
|
30
30
|
// Source interface
|
31
|
-
|
32
|
-
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
33
|
-
LocalSourceState &lstate) const override;
|
31
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
34
32
|
|
35
33
|
bool IsSource() const override {
|
36
34
|
return true;
|
@@ -30,8 +30,7 @@ public:
|
|
30
30
|
|
31
31
|
public:
|
32
32
|
// Source interface
|
33
|
-
|
34
|
-
LocalSourceState &lstate) const override;
|
33
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const override;
|
35
34
|
|
36
35
|
bool IsSource() const override {
|
37
36
|
return true;
|
@@ -39,8 +38,7 @@ public:
|
|
39
38
|
|
40
39
|
public:
|
41
40
|
// Sink interface
|
42
|
-
SinkResultType Sink(ExecutionContext &context,
|
43
|
-
DataChunk &input) const override;
|
41
|
+
SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override;
|
44
42
|
|
45
43
|
unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
|
46
44
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
#include "duckdb/common/types/data_chunk.hpp"
|
16
16
|
#include "duckdb/execution/execution_context.hpp"
|
17
17
|
#include "duckdb/optimizer/join_order/join_node.hpp"
|
18
|
+
#include "duckdb/common/optional_idx.hpp"
|
18
19
|
#include "duckdb/execution/physical_operator_states.hpp"
|
19
20
|
#include "duckdb/common/enums/order_preservation_type.hpp"
|
20
21
|
|
@@ -102,8 +103,8 @@ public:
|
|
102
103
|
virtual unique_ptr<LocalSourceState> GetLocalSourceState(ExecutionContext &context,
|
103
104
|
GlobalSourceState &gstate) const;
|
104
105
|
virtual unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const;
|
105
|
-
virtual
|
106
|
-
|
106
|
+
virtual SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const;
|
107
|
+
|
107
108
|
virtual idx_t GetBatchIndex(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
108
109
|
LocalSourceState &lstate) const;
|
109
110
|
|
@@ -132,8 +133,7 @@ public:
|
|
132
133
|
|
133
134
|
//! The sink method is called constantly with new input, as long as new input is available. Note that this method
|
134
135
|
//! CAN be called in parallel, proper locking is needed when accessing data inside the GlobalSinkState.
|
135
|
-
virtual SinkResultType Sink(ExecutionContext &context,
|
136
|
-
DataChunk &input) const;
|
136
|
+
virtual SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const;
|
137
137
|
// The combine is called when a single thread has completed execution of its part of the pipeline, it is the final
|
138
138
|
// time that a specific LocalSinkState is accessible. This method can be called in parallel while other Sink() or
|
139
139
|
// Combine() calls are active on the same GlobalSinkState.
|
@@ -143,6 +143,9 @@ public:
|
|
143
143
|
//! If Finalize returns SinkResultType::FINISHED, the sink is marked as finished
|
144
144
|
virtual SinkFinalizeType Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
|
145
145
|
GlobalSinkState &gstate) const;
|
146
|
+
//! For sinks with RequiresBatchIndex set to true, when a new batch starts being processed this method is called
|
147
|
+
//! This allows flushing of the current batch (e.g. to disk)
|
148
|
+
virtual void NextBatch(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate_p) const;
|
146
149
|
|
147
150
|
virtual unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) const;
|
148
151
|
virtual unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const;
|
@@ -23,6 +23,18 @@ class PhysicalOperator;
|
|
23
23
|
class Pipeline;
|
24
24
|
class PipelineBuildState;
|
25
25
|
class MetaPipeline;
|
26
|
+
class InterruptState;
|
27
|
+
|
28
|
+
struct SourcePartitionInfo {
|
29
|
+
//! The current batch index
|
30
|
+
//! This is only set in case RequiresBatchIndex() is true, and the source has support for it (SupportsBatchIndex())
|
31
|
+
//! Otherwise this is left on INVALID_INDEX
|
32
|
+
//! The batch index is a globally unique, increasing index that should be used to maintain insertion order
|
33
|
+
//! //! in conjunction with parallelism
|
34
|
+
optional_idx batch_index;
|
35
|
+
//! The minimum batch index that any thread is currently actively reading
|
36
|
+
optional_idx min_batch_index;
|
37
|
+
};
|
26
38
|
|
27
39
|
// LCOV_EXCL_START
|
28
40
|
class OperatorState {
|
@@ -88,12 +100,8 @@ public:
|
|
88
100
|
virtual ~LocalSinkState() {
|
89
101
|
}
|
90
102
|
|
91
|
-
//!
|
92
|
-
|
93
|
-
//! Otherwise this is left on INVALID_INDEX
|
94
|
-
//! The batch index is a globally unique, increasing index that should be used to maintain insertion order
|
95
|
-
//! //! in conjunction with parallelism
|
96
|
-
idx_t batch_index = DConstants::INVALID_INDEX;
|
103
|
+
//! Source partition info
|
104
|
+
SourcePartitionInfo partition_info;
|
97
105
|
|
98
106
|
template <class TARGET>
|
99
107
|
TARGET &Cast() {
|
@@ -145,6 +153,18 @@ public:
|
|
145
153
|
}
|
146
154
|
};
|
147
155
|
|
156
|
+
struct OperatorSinkInput {
|
157
|
+
GlobalSinkState &global_state;
|
158
|
+
LocalSinkState &local_state;
|
159
|
+
InterruptState &interrupt_state;
|
160
|
+
};
|
161
|
+
|
162
|
+
struct OperatorSourceInput {
|
163
|
+
GlobalSourceState &global_state;
|
164
|
+
LocalSourceState &local_state;
|
165
|
+
InterruptState &interrupt_state;
|
166
|
+
};
|
167
|
+
|
148
168
|
// LCOV_EXCL_STOP
|
149
169
|
|
150
170
|
} // namespace duckdb
|
@@ -41,20 +41,20 @@ public:
|
|
41
41
|
unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const;
|
42
42
|
unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) const;
|
43
43
|
|
44
|
-
void Sink(ExecutionContext &context,
|
45
|
-
|
44
|
+
void Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input, DataChunk &aggregate_input_chunk,
|
45
|
+
const vector<idx_t> &filter) const;
|
46
46
|
void Combine(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate) const;
|
47
47
|
bool Finalize(ClientContext &context, GlobalSinkState &gstate_p) const;
|
48
48
|
|
49
49
|
void ScheduleTasks(Executor &executor, const shared_ptr<Event> &event, GlobalSinkState &state,
|
50
|
-
vector<
|
50
|
+
vector<shared_ptr<Task>> &tasks) const;
|
51
51
|
|
52
52
|
//! Source interface
|
53
53
|
idx_t Size(GlobalSinkState &sink_state) const;
|
54
54
|
unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const;
|
55
55
|
unique_ptr<LocalSourceState> GetLocalSourceState(ExecutionContext &context) const;
|
56
|
-
|
57
|
-
|
56
|
+
SourceResultType GetData(ExecutionContext &context, DataChunk &chunk, GlobalSinkState &sink_state,
|
57
|
+
OperatorSourceInput &input) const;
|
58
58
|
|
59
59
|
static void SetMultiScan(GlobalSinkState &state);
|
60
60
|
bool ForceSingleHT(GlobalSinkState &state) const;
|
@@ -25,7 +25,8 @@ class BoundAggregateExpression;
|
|
25
25
|
|
26
26
|
struct AggregateInputData {
|
27
27
|
AggregateInputData(FunctionData *bind_data_p, Allocator &allocator_p)
|
28
|
-
: bind_data(bind_data_p), allocator(allocator_p) {
|
28
|
+
: bind_data(bind_data_p), allocator(allocator_p) {
|
29
|
+
}
|
29
30
|
FunctionData *bind_data;
|
30
31
|
Allocator &allocator;
|
31
32
|
};
|
@@ -182,7 +182,6 @@ typedef unique_ptr<LocalTableFunctionState> (*table_function_init_local_t)(Execu
|
|
182
182
|
typedef unique_ptr<BaseStatistics> (*table_statistics_t)(ClientContext &context, const FunctionData *bind_data,
|
183
183
|
column_t column_index);
|
184
184
|
typedef void (*table_function_t)(ClientContext &context, TableFunctionInput &data, DataChunk &output);
|
185
|
-
|
186
185
|
typedef OperatorResultType (*table_in_out_function_t)(ExecutionContext &context, TableFunctionInput &data,
|
187
186
|
DataChunk &input, DataChunk &output);
|
188
187
|
typedef OperatorFinalizeResultType (*table_in_out_function_final_t)(ExecutionContext &context, TableFunctionInput &data,
|
@@ -63,6 +63,8 @@ struct ClientConfig {
|
|
63
63
|
bool verify_serializer = false;
|
64
64
|
//! Enable the running of optimizers
|
65
65
|
bool enable_optimizer = true;
|
66
|
+
//! Enable caching operators
|
67
|
+
bool enable_caching_operators = true;
|
66
68
|
//! Force parallelism of small tables, used for testing
|
67
69
|
bool verify_parallelism = false;
|
68
70
|
//! Force index join independent of table cardinality, used for testing
|
@@ -149,6 +149,8 @@ struct DBConfigOptions {
|
|
149
149
|
DebugInitialize debug_initialize = DebugInitialize::NO_INITIALIZE;
|
150
150
|
//! The set of unrecognized (other) options
|
151
151
|
unordered_map<string, Value> unrecognized_options;
|
152
|
+
//! Whether to print bindings when printing the plan (debug mode only)
|
153
|
+
static bool debug_print_bindings;
|
152
154
|
|
153
155
|
bool operator==(const DBConfigOptions &other) const;
|
154
156
|
};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// src/include/duckdb/parallel/interrupt.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/common/atomic.hpp"
|
12
|
+
#include "duckdb/common/mutex.hpp"
|
13
|
+
#include "duckdb/parallel/task.hpp"
|
14
|
+
#include <condition_variable>
|
15
|
+
#include <memory>
|
16
|
+
|
17
|
+
namespace duckdb {
|
18
|
+
|
19
|
+
//! InterruptMode specifies how operators should block/unblock, note that this will happen transparently to the
|
20
|
+
//! operator, as the operator only needs to return a BLOCKED result and call the callback using the InterruptState.
|
21
|
+
//! NO_INTERRUPTS: No blocking mode is specified, an error will be thrown when the operator blocks. Should only be used
|
22
|
+
//! when manually calling operators of which is known they will never block.
|
23
|
+
//! TASK: A weak pointer to a task is provided. On the callback, this task will be signalled. If the Task has
|
24
|
+
//! been deleted, this callback becomes a NOP. This is the preferred way to await blocked pipelines.
|
25
|
+
//! BLOCKING: The caller has blocked awaiting some synchronization primitive to wait for the callback.
|
26
|
+
enum class InterruptMode : uint8_t { NO_INTERRUPTS, TASK, BLOCKING };
|
27
|
+
|
28
|
+
//! Synchronization primitive used to await a callback in InterruptMode::BLOCKING.
|
29
|
+
struct InterruptDoneSignalState {
|
30
|
+
//! Called by the callback to signal the interrupt is over
|
31
|
+
void Signal();
|
32
|
+
//! Await the callback signalling the interrupt is over
|
33
|
+
void Await();
|
34
|
+
|
35
|
+
protected:
|
36
|
+
mutex lock;
|
37
|
+
std::condition_variable cv;
|
38
|
+
bool done = false;
|
39
|
+
};
|
40
|
+
|
41
|
+
//! State required to make the callback after some asynchronous operation within an operator source / sink.
|
42
|
+
class InterruptState {
|
43
|
+
public:
|
44
|
+
//! Default interrupt state will be set to InterruptMode::NO_INTERRUPTS and throw an error on use of Callback()
|
45
|
+
InterruptState();
|
46
|
+
//! Register the task to be interrupted and set mode to InterruptMode::TASK, the preferred way to handle interrupts
|
47
|
+
InterruptState(weak_ptr<Task> task);
|
48
|
+
//! Register signal state and set mode to InterruptMode::BLOCKING, used for code paths without Task.
|
49
|
+
InterruptState(weak_ptr<InterruptDoneSignalState> done_signal);
|
50
|
+
|
51
|
+
//! Perform the callback to indicate the Interrupt is over
|
52
|
+
DUCKDB_API void Callback() const;
|
53
|
+
|
54
|
+
protected:
|
55
|
+
//! Current interrupt mode
|
56
|
+
InterruptMode mode;
|
57
|
+
//! Task ptr for InterruptMode::TASK
|
58
|
+
weak_ptr<Task> current_task;
|
59
|
+
//! Signal state for InterruptMode::BLOCKING
|
60
|
+
weak_ptr<InterruptDoneSignalState> signal_state;
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace duckdb
|
@@ -9,6 +9,8 @@
|
|
9
9
|
#pragma once
|
10
10
|
|
11
11
|
#include "duckdb/common/atomic.hpp"
|
12
|
+
#include "duckdb/common/unordered_set.hpp"
|
13
|
+
#include "duckdb/common/set.hpp"
|
12
14
|
#include "duckdb/execution/physical_operator.hpp"
|
13
15
|
#include "duckdb/function/table_function.hpp"
|
14
16
|
#include "duckdb/parallel/task_scheduler.hpp"
|
@@ -64,9 +66,7 @@ public:
|
|
64
66
|
void Reset();
|
65
67
|
void ResetSink();
|
66
68
|
void ResetSource(bool force);
|
67
|
-
void ClearSource()
|
68
|
-
source_state.reset();
|
69
|
-
}
|
69
|
+
void ClearSource();
|
70
70
|
void Schedule(shared_ptr<Event> &event);
|
71
71
|
|
72
72
|
//! Finalize this pipeline
|
@@ -94,6 +94,12 @@ public:
|
|
94
94
|
//! Returns whether any of the operators in the pipeline care about preserving order
|
95
95
|
bool IsOrderDependent() const;
|
96
96
|
|
97
|
+
//! Registers a new batch index for a pipeline executor - returns the current minimum batch index
|
98
|
+
idx_t RegisterNewBatchIndex();
|
99
|
+
|
100
|
+
//! Updates the batch index of a pipeline (and returns the new minimum batch index)
|
101
|
+
idx_t UpdateBatchIndex(idx_t old_index, idx_t new_index);
|
102
|
+
|
97
103
|
private:
|
98
104
|
//! Whether or not the pipeline has been readied
|
99
105
|
bool ready;
|
@@ -116,6 +122,13 @@ private:
|
|
116
122
|
|
117
123
|
//! The base batch index of this pipeline
|
118
124
|
idx_t base_batch_index = 0;
|
125
|
+
//! Lock for accessing the set of batch indexes
|
126
|
+
mutex batch_lock;
|
127
|
+
//! The set of batch indexes that are currently being processed
|
128
|
+
//! Despite batch indexes being unique - this is a multiset
|
129
|
+
//! The reason is that when we start a new pipeline we insert the current minimum batch index as a placeholder
|
130
|
+
//! Which leads to duplicate entries in the set of active batch indexes
|
131
|
+
multiset<idx_t> batch_indexes;
|
119
132
|
|
120
133
|
private:
|
121
134
|
void ScheduleSequentialTask(shared_ptr<Event> &event);
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#pragma once
|
10
10
|
|
11
11
|
#include "duckdb/common/types/data_chunk.hpp"
|
12
|
+
#include "duckdb/parallel/interrupt.hpp"
|
12
13
|
#include "duckdb/parallel/pipeline.hpp"
|
13
14
|
#include "duckdb/execution/physical_operator.hpp"
|
14
15
|
#include "duckdb/parallel/thread_context.hpp"
|
@@ -20,16 +21,27 @@
|
|
20
21
|
namespace duckdb {
|
21
22
|
class Executor;
|
22
23
|
|
24
|
+
//! The result of executing a PipelineExecutor
|
25
|
+
enum class PipelineExecuteResult {
|
26
|
+
//! PipelineExecutor is fully executed: the source is completely exhausted
|
27
|
+
FINISHED,
|
28
|
+
//! PipelineExecutor is not yet fully executed and can be called again immediately
|
29
|
+
NOT_FINISHED,
|
30
|
+
//! The PipelineExecutor was interrupted and should not be called again until the interrupt is handled as specified
|
31
|
+
//! in the InterruptMode
|
32
|
+
INTERRUPTED
|
33
|
+
};
|
34
|
+
|
23
35
|
//! The Pipeline class represents an execution pipeline
|
24
36
|
class PipelineExecutor {
|
25
37
|
public:
|
26
38
|
PipelineExecutor(ClientContext &context, Pipeline &pipeline);
|
27
39
|
|
28
40
|
//! Fully execute a pipeline with a source and a sink until the source is completely exhausted
|
29
|
-
|
30
|
-
//! Execute a pipeline with a source and a sink until finished, or until max_chunks
|
41
|
+
PipelineExecuteResult Execute();
|
42
|
+
//! Execute a pipeline with a source and a sink until finished, or until max_chunks were processed from the source
|
31
43
|
//! Returns true if execution is finished, false if Execute should be called again
|
32
|
-
|
44
|
+
PipelineExecuteResult Execute(idx_t max_chunks);
|
33
45
|
|
34
46
|
//! Push a single input DataChunk into the pipeline.
|
35
47
|
//! Returns either OperatorResultType::NEED_MORE_INPUT or OperatorResultType::FINISHED
|
@@ -48,6 +60,9 @@ public:
|
|
48
60
|
//! This flushes profiler states
|
49
61
|
void PullFinalize();
|
50
62
|
|
63
|
+
//! Registers the task in the interrupt_state to allow Source/Sink operators to block the task
|
64
|
+
void SetTaskForInterrupts(weak_ptr<Task> current_task);
|
65
|
+
|
51
66
|
private:
|
52
67
|
//! The pipeline to process
|
53
68
|
Pipeline &pipeline;
|
@@ -65,6 +80,8 @@ private:
|
|
65
80
|
unique_ptr<LocalSourceState> local_source_state;
|
66
81
|
//! The local sink state (if any)
|
67
82
|
unique_ptr<LocalSinkState> local_sink_state;
|
83
|
+
//! The interrupt state, holding required information for sink/source operators to block
|
84
|
+
InterruptState interrupt_state;
|
68
85
|
|
69
86
|
//! The final chunk used for moving data into the sink
|
70
87
|
DataChunk final_chunk;
|
@@ -79,28 +96,55 @@ private:
|
|
79
96
|
//! Whether or not this pipeline requires keeping track of the batch index of the source
|
80
97
|
bool requires_batch_index = false;
|
81
98
|
|
99
|
+
//! Source has indicated it is exhausted
|
100
|
+
bool exhausted_source = false;
|
101
|
+
//! Flushing of intermediate operators has started
|
102
|
+
bool started_flushing = false;
|
103
|
+
//! Flushing of caching operators is done
|
104
|
+
bool done_flushing = false;
|
105
|
+
|
106
|
+
//! This flag is set when the pipeline gets interrupted by the Sink -> the final_chunk should be re-sink-ed.
|
107
|
+
bool remaining_sink_chunk = false;
|
108
|
+
|
109
|
+
//! Current operator being flushed
|
110
|
+
idx_t flushing_idx;
|
111
|
+
//! Whether the current flushing_idx should be flushed: this needs to be stored to make flushing code re-entrant
|
112
|
+
bool should_flush_current_idx = true;
|
113
|
+
|
82
114
|
private:
|
83
115
|
void StartOperator(PhysicalOperator &op);
|
84
116
|
void EndOperator(PhysicalOperator &op, optional_ptr<DataChunk> chunk);
|
85
117
|
|
86
118
|
//! Reset the operator index to the first operator
|
87
119
|
void GoToSource(idx_t ¤t_idx, idx_t initial_idx);
|
88
|
-
|
120
|
+
SourceResultType FetchFromSource(DataChunk &result);
|
89
121
|
|
90
122
|
void FinishProcessing(int32_t operator_idx = -1);
|
91
123
|
bool IsFinished();
|
92
124
|
|
125
|
+
//! Wrappers for sink/source calls to respective operators
|
126
|
+
SourceResultType GetData(DataChunk &chunk, OperatorSourceInput &input);
|
127
|
+
SinkResultType Sink(DataChunk &chunk, OperatorSinkInput &input);
|
128
|
+
|
93
129
|
OperatorResultType ExecutePushInternal(DataChunk &input, idx_t initial_idx = 0);
|
94
130
|
//! Pushes a chunk through the pipeline and returns a single result chunk
|
95
131
|
//! Returns whether or not a new input chunk is needed, or whether or not we are finished
|
96
132
|
OperatorResultType Execute(DataChunk &input, DataChunk &result, idx_t initial_index = 0);
|
97
133
|
|
98
|
-
//!
|
99
|
-
|
100
|
-
|
134
|
+
//! Tries to flush all state from intermediate operators. Will return true if all state is flushed, false in the
|
135
|
+
//! case of a blocked sink.
|
136
|
+
bool TryFlushCachingOperators();
|
101
137
|
|
102
138
|
static bool CanCacheType(const LogicalType &type);
|
103
139
|
void CacheChunk(DataChunk &input, idx_t operator_idx);
|
140
|
+
|
141
|
+
#ifdef DUCKDB_DEBUG_ASYNC_SINK_SOURCE
|
142
|
+
//! Debugging state: number of times blocked
|
143
|
+
int debug_blocked_sink_count = 0;
|
144
|
+
int debug_blocked_source_count = 0;
|
145
|
+
//! Number of times the Sink/Source will block before actually returning data
|
146
|
+
int debug_blocked_target_count = 1;
|
147
|
+
#endif
|
104
148
|
};
|
105
149
|
|
106
150
|
} // namespace duckdb
|
@@ -13,13 +13,16 @@
|
|
13
13
|
namespace duckdb {
|
14
14
|
class ClientContext;
|
15
15
|
class Executor;
|
16
|
+
class Task;
|
17
|
+
class DatabaseInstance;
|
18
|
+
struct ProducerToken;
|
16
19
|
|
17
20
|
enum class TaskExecutionMode : uint8_t { PROCESS_ALL, PROCESS_PARTIAL };
|
18
21
|
|
19
|
-
enum class TaskExecutionResult : uint8_t { TASK_FINISHED, TASK_NOT_FINISHED, TASK_ERROR };
|
22
|
+
enum class TaskExecutionResult : uint8_t { TASK_FINISHED, TASK_NOT_FINISHED, TASK_ERROR, TASK_BLOCKED };
|
20
23
|
|
21
24
|
//! Generic parallel task
|
22
|
-
class Task {
|
25
|
+
class Task : public std::enable_shared_from_this<Task> {
|
23
26
|
public:
|
24
27
|
virtual ~Task() {
|
25
28
|
}
|
@@ -28,7 +31,20 @@ public:
|
|
28
31
|
//! If mode is PROCESS_ALL, Execute should always finish processing and return TASK_FINISHED
|
29
32
|
//! If mode is PROCESS_PARTIAL, Execute can return TASK_NOT_FINISHED, in which case Execute will be called again
|
30
33
|
//! In case of an error, TASK_ERROR is returned
|
34
|
+
//! In case the task has interrupted, BLOCKED is returned.
|
31
35
|
virtual TaskExecutionResult Execute(TaskExecutionMode mode) = 0;
|
36
|
+
|
37
|
+
//! Descheduling a task ensures the task is not executed, but remains available for rescheduling as long as
|
38
|
+
//! required, generally until some code in an operator calls the InterruptState::Callback() method of a state of the
|
39
|
+
//! InterruptMode::TASK mode.
|
40
|
+
virtual void Deschedule() {
|
41
|
+
throw InternalException("Cannot deschedule task of base Task class");
|
42
|
+
};
|
43
|
+
|
44
|
+
//! Ensures a task is rescheduled to the correct queue
|
45
|
+
virtual void Reschedule() {
|
46
|
+
throw InternalException("Cannot reschedule task of base Task class");
|
47
|
+
}
|
32
48
|
};
|
33
49
|
|
34
50
|
//! Execute a task within an executor, including exception handling
|
@@ -39,6 +55,9 @@ public:
|
|
39
55
|
ExecutorTask(ClientContext &context);
|
40
56
|
virtual ~ExecutorTask();
|
41
57
|
|
58
|
+
void Deschedule() override;
|
59
|
+
void Reschedule() override;
|
60
|
+
|
42
61
|
Executor &executor;
|
43
62
|
|
44
63
|
public:
|
@@ -18,7 +18,7 @@ public:
|
|
18
18
|
: scheduler(scheduler_p), token(scheduler_p.CreateProducer()), task_count(0), tasks_completed(0) {
|
19
19
|
}
|
20
20
|
|
21
|
-
virtual void AddTask(
|
21
|
+
virtual void AddTask(shared_ptr<Task> task) {
|
22
22
|
++task_count;
|
23
23
|
scheduler.ScheduleTask(*token, std::move(task));
|
24
24
|
}
|
@@ -29,7 +29,7 @@ public:
|
|
29
29
|
|
30
30
|
virtual void Finish() {
|
31
31
|
while (tasks_completed < task_count) {
|
32
|
-
|
32
|
+
shared_ptr<Task> task;
|
33
33
|
if (scheduler.GetTaskFromProducer(*token, task)) {
|
34
34
|
task->Execute();
|
35
35
|
task.reset();
|
@@ -47,9 +47,9 @@ public:
|
|
47
47
|
|
48
48
|
unique_ptr<ProducerToken> CreateProducer();
|
49
49
|
//! Schedule a task to be executed by the task scheduler
|
50
|
-
void ScheduleTask(ProducerToken &producer,
|
50
|
+
void ScheduleTask(ProducerToken &producer, shared_ptr<Task> task);
|
51
51
|
//! Fetches a task from a specific producer, returns true if successful or false if no tasks were available
|
52
|
-
bool GetTaskFromProducer(ProducerToken &token,
|
52
|
+
bool GetTaskFromProducer(ProducerToken &token, shared_ptr<Task> &task);
|
53
53
|
//! Run tasks forever until "marker" is set to false, "marker" must remain valid until the thread is joined
|
54
54
|
void ExecuteForever(atomic<bool> *marker);
|
55
55
|
//! Run tasks until `marker` is set to false, `max_tasks` have been completed, or until there are no more tasks
|
@@ -9,6 +9,8 @@
|
|
9
9
|
#pragma once
|
10
10
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
12
|
+
#include "duckdb/common/to_string.hpp"
|
13
|
+
|
12
14
|
#include <functional>
|
13
15
|
|
14
16
|
namespace duckdb {
|
@@ -23,6 +25,10 @@ struct ColumnBinding {
|
|
23
25
|
ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
|
24
26
|
}
|
25
27
|
|
28
|
+
string ToString() const {
|
29
|
+
return "#[" + to_string(table_index) + "." + to_string(column_index) + "]";
|
30
|
+
}
|
31
|
+
|
26
32
|
bool operator==(const ColumnBinding &rhs) const {
|
27
33
|
return table_index == rhs.table_index && column_index == rhs.column_index;
|
28
34
|
}
|
@@ -47,6 +47,7 @@ public:
|
|
47
47
|
static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
|
48
48
|
idx_t EstimateCardinality(ClientContext &context) override;
|
49
49
|
vector<idx_t> GetTableIndex() const override;
|
50
|
+
string GetName() const override;
|
50
51
|
|
51
52
|
protected:
|
52
53
|
void ResolveTypes() override;
|
@@ -34,6 +34,7 @@ public:
|
|
34
34
|
void Serialize(FieldWriter &writer) const override;
|
35
35
|
static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
|
36
36
|
vector<idx_t> GetTableIndex() const override;
|
37
|
+
string GetName() const override;
|
37
38
|
|
38
39
|
protected:
|
39
40
|
void ResolveTypes() override {
|
@@ -41,6 +41,7 @@ public:
|
|
41
41
|
void Serialize(FieldWriter &writer) const override;
|
42
42
|
static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
|
43
43
|
vector<idx_t> GetTableIndex() const override;
|
44
|
+
string GetName() const override;
|
44
45
|
|
45
46
|
protected:
|
46
47
|
void ResolveTypes() override {
|