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
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "duckdb/parallel/base_pipeline_event.hpp"
|
13
13
|
#include "duckdb/common/unordered_set.hpp"
|
14
14
|
#include "duckdb/common/algorithm.hpp"
|
15
|
+
#include "duckdb/parallel/interrupt.hpp"
|
15
16
|
#include <functional>
|
16
17
|
#include "duckdb/execution/operator/aggregate/distinct_aggregate_data.hpp"
|
17
18
|
|
@@ -186,10 +187,10 @@ unique_ptr<LocalSinkState> PhysicalUngroupedAggregate::GetLocalSinkState(Executi
|
|
186
187
|
return make_uniq<UngroupedAggregateLocalState>(*this, children[0]->GetTypes(), gstate, context);
|
187
188
|
}
|
188
189
|
|
189
|
-
void PhysicalUngroupedAggregate::SinkDistinct(ExecutionContext &context,
|
190
|
-
|
191
|
-
auto &sink =
|
192
|
-
auto &global_sink =
|
190
|
+
void PhysicalUngroupedAggregate::SinkDistinct(ExecutionContext &context, DataChunk &chunk,
|
191
|
+
OperatorSinkInput &input) const {
|
192
|
+
auto &sink = input.local_state.Cast<UngroupedAggregateLocalState>();
|
193
|
+
auto &global_sink = input.global_state.Cast<UngroupedAggregateGlobalState>();
|
193
194
|
D_ASSERT(distinct_data);
|
194
195
|
auto &distinct_state = *global_sink.distinct_state;
|
195
196
|
auto &distinct_info = *distinct_collection_info;
|
@@ -211,6 +212,7 @@ void PhysicalUngroupedAggregate::SinkDistinct(ExecutionContext &context, GlobalS
|
|
211
212
|
auto &radix_table = *distinct_data->radix_tables[table_idx];
|
212
213
|
auto &radix_global_sink = *distinct_state.radix_states[table_idx];
|
213
214
|
auto &radix_local_sink = *sink.radix_states[table_idx];
|
215
|
+
OperatorSinkInput sink_input {radix_global_sink, radix_local_sink, input.interrupt_state};
|
214
216
|
|
215
217
|
if (aggregate.filter) {
|
216
218
|
// The hashtable can apply a filter, but only on the payload
|
@@ -218,26 +220,25 @@ void PhysicalUngroupedAggregate::SinkDistinct(ExecutionContext &context, GlobalS
|
|
218
220
|
|
219
221
|
// Apply the filter before inserting into the hashtable
|
220
222
|
auto &filtered_data = sink.filter_set.GetFilterData(idx);
|
221
|
-
idx_t count = filtered_data.ApplyFilter(
|
223
|
+
idx_t count = filtered_data.ApplyFilter(chunk);
|
222
224
|
filtered_data.filtered_payload.SetCardinality(count);
|
223
225
|
|
224
|
-
radix_table.Sink(context,
|
225
|
-
distinct_filter);
|
226
|
+
radix_table.Sink(context, filtered_data.filtered_payload, sink_input, empty_chunk, distinct_filter);
|
226
227
|
} else {
|
227
|
-
radix_table.Sink(context,
|
228
|
+
radix_table.Sink(context, chunk, sink_input, empty_chunk, distinct_filter);
|
228
229
|
}
|
229
230
|
}
|
230
231
|
}
|
231
232
|
|
232
|
-
SinkResultType PhysicalUngroupedAggregate::Sink(ExecutionContext &context,
|
233
|
-
|
234
|
-
auto &sink =
|
233
|
+
SinkResultType PhysicalUngroupedAggregate::Sink(ExecutionContext &context, DataChunk &chunk,
|
234
|
+
OperatorSinkInput &input) const {
|
235
|
+
auto &sink = input.local_state.Cast<UngroupedAggregateLocalState>();
|
235
236
|
|
236
237
|
// perform the aggregation inside the local state
|
237
238
|
sink.Reset();
|
238
239
|
|
239
240
|
if (distinct_data) {
|
240
|
-
SinkDistinct(context,
|
241
|
+
SinkDistinct(context, chunk, input);
|
241
242
|
}
|
242
243
|
|
243
244
|
DataChunk &payload_chunk = sink.aggregate_input_chunk;
|
@@ -259,13 +260,13 @@ SinkResultType PhysicalUngroupedAggregate::Sink(ExecutionContext &context, Globa
|
|
259
260
|
// resolve the filter (if any)
|
260
261
|
if (aggregate.filter) {
|
261
262
|
auto &filtered_data = sink.filter_set.GetFilterData(aggr_idx);
|
262
|
-
auto count = filtered_data.ApplyFilter(
|
263
|
+
auto count = filtered_data.ApplyFilter(chunk);
|
263
264
|
|
264
265
|
sink.child_executor.SetChunk(filtered_data.filtered_payload);
|
265
266
|
payload_chunk.SetCardinality(count);
|
266
267
|
} else {
|
267
|
-
sink.child_executor.SetChunk(
|
268
|
-
payload_chunk.SetCardinality(
|
268
|
+
sink.child_executor.SetChunk(chunk);
|
269
|
+
payload_chunk.SetCardinality(chunk);
|
269
270
|
}
|
270
271
|
|
271
272
|
#ifdef DEBUG
|
@@ -396,10 +397,17 @@ public:
|
|
396
397
|
//! Retrieve the stored data from the hashtable
|
397
398
|
while (true) {
|
398
399
|
output_chunk.Reset();
|
399
|
-
|
400
|
-
|
401
|
-
|
400
|
+
|
401
|
+
InterruptState interrupt_state;
|
402
|
+
OperatorSourceInput source_input {*global_source_state, *local_source_state, interrupt_state};
|
403
|
+
auto res = radix_table_p->GetData(temp_exec_context, output_chunk,
|
404
|
+
*distinct_state.radix_states[table_idx], source_input);
|
405
|
+
if (res == SourceResultType::FINISHED) {
|
406
|
+
D_ASSERT(output_chunk.size() == 0);
|
402
407
|
break;
|
408
|
+
} else if (res == SourceResultType::BLOCKED) {
|
409
|
+
throw InternalException(
|
410
|
+
"Unexpected interrupt from radix table GetData in UngroupedDistinctAggregateFinalizeTask");
|
403
411
|
}
|
404
412
|
|
405
413
|
// We dont need to resolve the filter, we already did this in Sink
|
@@ -450,7 +458,7 @@ public:
|
|
450
458
|
|
451
459
|
public:
|
452
460
|
void Schedule() override {
|
453
|
-
vector<
|
461
|
+
vector<shared_ptr<Task>> tasks;
|
454
462
|
tasks.push_back(make_uniq<UngroupedDistinctAggregateFinalizeTask>(pipeline->executor, shared_from_this(),
|
455
463
|
gstate, context, op));
|
456
464
|
D_ASSERT(!tasks.empty());
|
@@ -474,7 +482,7 @@ public:
|
|
474
482
|
void Schedule() override {
|
475
483
|
auto &distinct_state = *gstate.distinct_state;
|
476
484
|
auto &distinct_data = *op.distinct_data;
|
477
|
-
vector<
|
485
|
+
vector<shared_ptr<Task>> tasks;
|
478
486
|
for (idx_t table_idx = 0; table_idx < distinct_data.radix_tables.size(); table_idx++) {
|
479
487
|
distinct_data.radix_tables[table_idx]->ScheduleTasks(pipeline->executor, shared_from_this(),
|
480
488
|
*distinct_state.radix_states[table_idx], tasks);
|
@@ -533,18 +541,6 @@ SinkFinalizeType PhysicalUngroupedAggregate::Finalize(Pipeline &pipeline, Event
|
|
533
541
|
//===--------------------------------------------------------------------===//
|
534
542
|
// Source
|
535
543
|
//===--------------------------------------------------------------------===//
|
536
|
-
class UngroupedAggregateState : public GlobalSourceState {
|
537
|
-
public:
|
538
|
-
UngroupedAggregateState() : finished(false) {
|
539
|
-
}
|
540
|
-
|
541
|
-
bool finished;
|
542
|
-
};
|
543
|
-
|
544
|
-
unique_ptr<GlobalSourceState> PhysicalUngroupedAggregate::GetGlobalSourceState(ClientContext &context) const {
|
545
|
-
return make_uniq<UngroupedAggregateState>();
|
546
|
-
}
|
547
|
-
|
548
544
|
void VerifyNullHandling(DataChunk &chunk, AggregateState &state, const vector<unique_ptr<Expression>> &aggregates) {
|
549
545
|
#ifdef DEBUG
|
550
546
|
for (idx_t aggr_idx = 0; aggr_idx < aggregates.size(); aggr_idx++) {
|
@@ -559,14 +555,10 @@ void VerifyNullHandling(DataChunk &chunk, AggregateState &state, const vector<un
|
|
559
555
|
#endif
|
560
556
|
}
|
561
557
|
|
562
|
-
|
563
|
-
|
558
|
+
SourceResultType PhysicalUngroupedAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
|
559
|
+
OperatorSourceInput &input) const {
|
564
560
|
auto &gstate = sink_state->Cast<UngroupedAggregateGlobalState>();
|
565
|
-
auto &state = (UngroupedAggregateState &)gstate_p;
|
566
561
|
D_ASSERT(gstate.finished);
|
567
|
-
if (state.finished) {
|
568
|
-
return;
|
569
|
-
}
|
570
562
|
|
571
563
|
// initialize the result chunk with the aggregate values
|
572
564
|
chunk.SetCardinality(1);
|
@@ -578,7 +570,8 @@ void PhysicalUngroupedAggregate::GetData(ExecutionContext &context, DataChunk &c
|
|
578
570
|
aggregate.function.finalize(state_vector, aggr_input_data, chunk.data[aggr_idx], 1, 0);
|
579
571
|
}
|
580
572
|
VerifyNullHandling(chunk, gstate.state, aggregates);
|
581
|
-
|
573
|
+
|
574
|
+
return SourceResultType::FINISHED;
|
582
575
|
}
|
583
576
|
|
584
577
|
string PhysicalUngroupedAggregate::ParamsToString() const {
|
@@ -1036,11 +1036,10 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1036
1036
|
//===--------------------------------------------------------------------===//
|
1037
1037
|
// Sink
|
1038
1038
|
//===--------------------------------------------------------------------===//
|
1039
|
-
SinkResultType PhysicalWindow::Sink(ExecutionContext &context,
|
1040
|
-
|
1041
|
-
auto &lstate = lstate_p.Cast<WindowLocalSinkState>();
|
1039
|
+
SinkResultType PhysicalWindow::Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const {
|
1040
|
+
auto &lstate = input.local_state.Cast<WindowLocalSinkState>();
|
1042
1041
|
|
1043
|
-
lstate.Sink(
|
1042
|
+
lstate.Sink(chunk);
|
1044
1043
|
|
1045
1044
|
return SinkResultType::NEED_MORE_INPUT;
|
1046
1045
|
}
|
@@ -1339,10 +1338,10 @@ unique_ptr<GlobalSourceState> PhysicalWindow::GetGlobalSourceState(ClientContext
|
|
1339
1338
|
return make_uniq<WindowGlobalSourceState>(gsink);
|
1340
1339
|
}
|
1341
1340
|
|
1342
|
-
|
1343
|
-
|
1344
|
-
auto &lsource =
|
1345
|
-
auto &gsource =
|
1341
|
+
SourceResultType PhysicalWindow::GetData(ExecutionContext &context, DataChunk &chunk,
|
1342
|
+
OperatorSourceInput &input) const {
|
1343
|
+
auto &lsource = input.local_state.Cast<WindowLocalSourceState>();
|
1344
|
+
auto &gsource = input.global_state.Cast<WindowGlobalSourceState>();
|
1346
1345
|
auto &gsink = sink_state->Cast<WindowGlobalSinkState>();
|
1347
1346
|
|
1348
1347
|
auto &hash_groups = gsink.global_partition->hash_groups;
|
@@ -1357,7 +1356,7 @@ void PhysicalWindow::GetData(ExecutionContext &context, DataChunk &chunk, Global
|
|
1357
1356
|
lsource.hash_group.reset();
|
1358
1357
|
auto hash_bin = gsource.next_bin++;
|
1359
1358
|
if (hash_bin >= bin_count) {
|
1360
|
-
return;
|
1359
|
+
return chunk.size() > 0 ? SourceResultType::HAVE_MORE_OUTPUT : SourceResultType::FINISHED;
|
1361
1360
|
}
|
1362
1361
|
|
1363
1362
|
for (; hash_bin < hash_groups.size(); hash_bin = gsource.next_bin++) {
|
@@ -1370,6 +1369,8 @@ void PhysicalWindow::GetData(ExecutionContext &context, DataChunk &chunk, Global
|
|
1370
1369
|
|
1371
1370
|
lsource.Scan(chunk);
|
1372
1371
|
}
|
1372
|
+
|
1373
|
+
return chunk.size() == 0 ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
|
1373
1374
|
}
|
1374
1375
|
|
1375
1376
|
string PhysicalWindow::ParamsToString() const {
|
@@ -29,10 +29,10 @@ public:
|
|
29
29
|
BatchedDataCollection data;
|
30
30
|
};
|
31
31
|
|
32
|
-
SinkResultType PhysicalBatchCollector::Sink(ExecutionContext &context,
|
33
|
-
|
34
|
-
auto &state =
|
35
|
-
state.data.Append(
|
32
|
+
SinkResultType PhysicalBatchCollector::Sink(ExecutionContext &context, DataChunk &chunk,
|
33
|
+
OperatorSinkInput &input) const {
|
34
|
+
auto &state = input.local_state.Cast<BatchCollectorLocalState>();
|
35
|
+
state.data.Append(chunk, state.partition_info.batch_index.GetIndex());
|
36
36
|
return SinkResultType::NEED_MORE_INPUT;
|
37
37
|
}
|
38
38
|
|
@@ -12,8 +12,8 @@ public:
|
|
12
12
|
string analyzed_plan;
|
13
13
|
};
|
14
14
|
|
15
|
-
SinkResultType PhysicalExplainAnalyze::Sink(ExecutionContext &context,
|
16
|
-
|
15
|
+
SinkResultType PhysicalExplainAnalyze::Sink(ExecutionContext &context, DataChunk &chunk,
|
16
|
+
OperatorSinkInput &input) const {
|
17
17
|
return SinkResultType::NEED_MORE_INPUT;
|
18
18
|
}
|
19
19
|
|
@@ -32,30 +32,15 @@ unique_ptr<GlobalSinkState> PhysicalExplainAnalyze::GetGlobalSinkState(ClientCon
|
|
32
32
|
//===--------------------------------------------------------------------===//
|
33
33
|
// Source
|
34
34
|
//===--------------------------------------------------------------------===//
|
35
|
-
|
36
|
-
|
37
|
-
ExplainAnalyzeState() : finished(false) {
|
38
|
-
}
|
39
|
-
|
40
|
-
bool finished;
|
41
|
-
};
|
42
|
-
|
43
|
-
unique_ptr<GlobalSourceState> PhysicalExplainAnalyze::GetGlobalSourceState(ClientContext &context) const {
|
44
|
-
return make_uniq<ExplainAnalyzeState>();
|
45
|
-
}
|
46
|
-
|
47
|
-
void PhysicalExplainAnalyze::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &source_state,
|
48
|
-
LocalSourceState &lstate) const {
|
49
|
-
auto &state = (ExplainAnalyzeState &)source_state;
|
35
|
+
SourceResultType PhysicalExplainAnalyze::GetData(ExecutionContext &context, DataChunk &chunk,
|
36
|
+
OperatorSourceInput &input) const {
|
50
37
|
auto &gstate = sink_state->Cast<ExplainAnalyzeStateGlobalState>();
|
51
|
-
|
52
|
-
return;
|
53
|
-
}
|
38
|
+
|
54
39
|
chunk.SetValue(0, 0, Value("analyzed_plan"));
|
55
40
|
chunk.SetValue(1, 0, Value(gstate.analyzed_plan));
|
56
41
|
chunk.SetCardinality(1);
|
57
42
|
|
58
|
-
|
43
|
+
return SourceResultType::FINISHED;
|
59
44
|
}
|
60
45
|
|
61
46
|
} // namespace duckdb
|
@@ -92,25 +92,24 @@ bool PhysicalLimit::ComputeOffset(ExecutionContext &context, DataChunk &input, i
|
|
92
92
|
return true;
|
93
93
|
}
|
94
94
|
|
95
|
-
SinkResultType PhysicalLimit::Sink(ExecutionContext &context,
|
96
|
-
DataChunk &input) const {
|
95
|
+
SinkResultType PhysicalLimit::Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const {
|
97
96
|
|
98
|
-
D_ASSERT(
|
99
|
-
auto &state =
|
97
|
+
D_ASSERT(chunk.size() > 0);
|
98
|
+
auto &state = input.local_state.Cast<LimitLocalState>();
|
100
99
|
auto &limit = state.limit;
|
101
100
|
auto &offset = state.offset;
|
102
101
|
|
103
102
|
idx_t max_element;
|
104
|
-
if (!ComputeOffset(context,
|
103
|
+
if (!ComputeOffset(context, chunk, limit, offset, state.current_offset, max_element, limit_expression.get(),
|
105
104
|
offset_expression.get())) {
|
106
105
|
return SinkResultType::FINISHED;
|
107
106
|
}
|
108
107
|
auto max_cardinality = max_element - state.current_offset;
|
109
|
-
if (max_cardinality <
|
110
|
-
|
108
|
+
if (max_cardinality < chunk.size()) {
|
109
|
+
chunk.SetCardinality(max_cardinality);
|
111
110
|
}
|
112
|
-
state.data.Append(
|
113
|
-
state.current_offset +=
|
111
|
+
state.data.Append(chunk, state.partition_info.batch_index.GetIndex());
|
112
|
+
state.current_offset += chunk.size();
|
114
113
|
if (state.current_offset == max_element) {
|
115
114
|
return SinkResultType::FINISHED;
|
116
115
|
}
|
@@ -146,10 +145,9 @@ unique_ptr<GlobalSourceState> PhysicalLimit::GetGlobalSourceState(ClientContext
|
|
146
145
|
return make_uniq<LimitSourceState>();
|
147
146
|
}
|
148
147
|
|
149
|
-
|
150
|
-
LocalSourceState &lstate) const {
|
148
|
+
SourceResultType PhysicalLimit::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
151
149
|
auto &gstate = sink_state->Cast<LimitGlobalState>();
|
152
|
-
auto &state =
|
150
|
+
auto &state = input.global_state.Cast<LimitSourceState>();
|
153
151
|
while (state.current_offset < gstate.limit + gstate.offset) {
|
154
152
|
if (!state.initialized) {
|
155
153
|
gstate.data.InitializeScan(state.scan_state);
|
@@ -157,12 +155,14 @@ void PhysicalLimit::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
157
155
|
}
|
158
156
|
gstate.data.Scan(state.scan_state, chunk);
|
159
157
|
if (chunk.size() == 0) {
|
160
|
-
|
158
|
+
return SourceResultType::FINISHED;
|
161
159
|
}
|
162
160
|
if (HandleOffset(chunk, state.current_offset, gstate.offset, gstate.limit)) {
|
163
161
|
break;
|
164
162
|
}
|
165
163
|
}
|
164
|
+
|
165
|
+
return chunk.size() > 0 ? SourceResultType::HAVE_MORE_OUTPUT : SourceResultType::FINISHED;
|
166
166
|
}
|
167
167
|
|
168
168
|
bool PhysicalLimit::HandleOffset(DataChunk &input, idx_t ¤t_offset, idx_t offset, idx_t limit) {
|
@@ -42,16 +42,15 @@ unique_ptr<GlobalSinkState> PhysicalLimitPercent::GetGlobalSinkState(ClientConte
|
|
42
42
|
return make_uniq<LimitPercentGlobalState>(context, *this);
|
43
43
|
}
|
44
44
|
|
45
|
-
SinkResultType PhysicalLimitPercent::Sink(ExecutionContext &context,
|
46
|
-
|
47
|
-
|
48
|
-
auto &state = gstate.Cast<LimitPercentGlobalState>();
|
45
|
+
SinkResultType PhysicalLimitPercent::Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const {
|
46
|
+
D_ASSERT(chunk.size() > 0);
|
47
|
+
auto &state = input.global_state.Cast<LimitPercentGlobalState>();
|
49
48
|
auto &limit_percent = state.limit_percent;
|
50
49
|
auto &offset = state.offset;
|
51
50
|
|
52
51
|
// get the next chunk from the child
|
53
52
|
if (!state.is_limit_percent_delimited) {
|
54
|
-
Value val = PhysicalLimit::GetDelimiter(context,
|
53
|
+
Value val = PhysicalLimit::GetDelimiter(context, chunk, limit_expression.get());
|
55
54
|
if (!val.IsNull()) {
|
56
55
|
limit_percent = val.GetValue<double>();
|
57
56
|
}
|
@@ -61,7 +60,7 @@ SinkResultType PhysicalLimitPercent::Sink(ExecutionContext &context, GlobalSinkS
|
|
61
60
|
state.is_limit_percent_delimited = true;
|
62
61
|
}
|
63
62
|
if (!state.is_offset_delimited) {
|
64
|
-
Value val = PhysicalLimit::GetDelimiter(context,
|
63
|
+
Value val = PhysicalLimit::GetDelimiter(context, chunk, offset_expression.get());
|
65
64
|
if (!val.IsNull()) {
|
66
65
|
offset = val.GetValue<idx_t>();
|
67
66
|
}
|
@@ -71,11 +70,11 @@ SinkResultType PhysicalLimitPercent::Sink(ExecutionContext &context, GlobalSinkS
|
|
71
70
|
state.is_offset_delimited = true;
|
72
71
|
}
|
73
72
|
|
74
|
-
if (!PhysicalLimit::HandleOffset(
|
73
|
+
if (!PhysicalLimit::HandleOffset(chunk, state.current_offset, offset, DConstants::INVALID_INDEX)) {
|
75
74
|
return SinkResultType::NEED_MORE_INPUT;
|
76
75
|
}
|
77
76
|
|
78
|
-
state.data.Append(
|
77
|
+
state.data.Append(chunk);
|
79
78
|
return SinkResultType::NEED_MORE_INPUT;
|
80
79
|
}
|
81
80
|
|
@@ -100,10 +99,10 @@ unique_ptr<GlobalSourceState> PhysicalLimitPercent::GetGlobalSourceState(ClientC
|
|
100
99
|
return make_uniq<LimitPercentOperatorState>(*this);
|
101
100
|
}
|
102
101
|
|
103
|
-
|
104
|
-
|
102
|
+
SourceResultType PhysicalLimitPercent::GetData(ExecutionContext &context, DataChunk &chunk,
|
103
|
+
OperatorSourceInput &input) const {
|
105
104
|
auto &gstate = sink_state->Cast<LimitPercentGlobalState>();
|
106
|
-
auto &state =
|
105
|
+
auto &state = input.global_state.Cast<LimitPercentOperatorState>();
|
107
106
|
auto &percent_limit = gstate.limit_percent;
|
108
107
|
auto &offset = gstate.offset;
|
109
108
|
auto &limit = state.limit;
|
@@ -124,18 +123,20 @@ void PhysicalLimitPercent::GetData(ExecutionContext &context, DataChunk &chunk,
|
|
124
123
|
limit = idx_t(limit_dbl);
|
125
124
|
}
|
126
125
|
if (limit == 0) {
|
127
|
-
return;
|
126
|
+
return SourceResultType::FINISHED;
|
128
127
|
}
|
129
128
|
}
|
130
129
|
|
131
130
|
if (current_offset >= limit) {
|
132
|
-
return;
|
131
|
+
return SourceResultType::FINISHED;
|
133
132
|
}
|
134
133
|
if (!gstate.data.Scan(state.scan_state, chunk)) {
|
135
|
-
return;
|
134
|
+
return SourceResultType::FINISHED;
|
136
135
|
}
|
137
136
|
|
138
137
|
PhysicalLimit::HandleOffset(chunk, current_offset, 0, limit);
|
138
|
+
|
139
|
+
return SourceResultType::HAVE_MORE_OUTPUT;
|
139
140
|
}
|
140
141
|
|
141
142
|
} // namespace duckdb
|
@@ -3,13 +3,14 @@
|
|
3
3
|
|
4
4
|
namespace duckdb {
|
5
5
|
|
6
|
-
|
7
|
-
LocalSourceState &lstate) const {
|
6
|
+
SourceResultType PhysicalLoad::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
8
7
|
if (info->load_type == LoadType::INSTALL || info->load_type == LoadType::FORCE_INSTALL) {
|
9
8
|
ExtensionHelper::InstallExtension(context.client, info->filename, info->load_type == LoadType::FORCE_INSTALL);
|
10
9
|
} else {
|
11
10
|
ExtensionHelper::LoadExternalExtension(context.client, info->filename);
|
12
11
|
}
|
12
|
+
|
13
|
+
return SourceResultType::FINISHED;
|
13
14
|
}
|
14
15
|
|
15
16
|
} // namespace duckdb
|
@@ -25,10 +25,10 @@ public:
|
|
25
25
|
ColumnDataAppendState append_state;
|
26
26
|
};
|
27
27
|
|
28
|
-
SinkResultType PhysicalMaterializedCollector::Sink(ExecutionContext &context,
|
29
|
-
|
30
|
-
auto &lstate =
|
31
|
-
lstate.collection->Append(lstate.append_state,
|
28
|
+
SinkResultType PhysicalMaterializedCollector::Sink(ExecutionContext &context, DataChunk &chunk,
|
29
|
+
OperatorSinkInput &input) const {
|
30
|
+
auto &lstate = input.local_state.Cast<MaterializedCollectorLocalState>();
|
31
|
+
lstate.collection->Append(lstate.append_state, chunk);
|
32
32
|
return SinkResultType::NEED_MORE_INPUT;
|
33
33
|
}
|
34
34
|
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
namespace duckdb {
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
SourceResultType PhysicalPragma::GetData(ExecutionContext &context, DataChunk &chunk,
|
6
|
+
OperatorSourceInput &input) const {
|
7
7
|
auto &client = context.client;
|
8
8
|
FunctionParameters parameters {info.parameters, info.named_parameters};
|
9
9
|
function.function(client, parameters);
|
10
|
+
|
11
|
+
return SourceResultType::FINISHED;
|
10
12
|
}
|
11
13
|
|
12
14
|
} // namespace duckdb
|
@@ -3,12 +3,14 @@
|
|
3
3
|
|
4
4
|
namespace duckdb {
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
SourceResultType PhysicalPrepare::GetData(ExecutionContext &context, DataChunk &chunk,
|
7
|
+
OperatorSourceInput &input) const {
|
8
8
|
auto &client = context.client;
|
9
9
|
|
10
10
|
// store the prepared statement in the context
|
11
11
|
ClientData::Get(client).prepared_statements[name] = prepared;
|
12
|
+
|
13
|
+
return SourceResultType::FINISHED;
|
12
14
|
}
|
13
15
|
|
14
16
|
} // namespace duckdb
|
@@ -34,9 +34,9 @@ unique_ptr<GlobalSinkState> PhysicalReservoirSample::GetGlobalSinkState(ClientCo
|
|
34
34
|
return make_uniq<SampleGlobalSinkState>(Allocator::Get(context), *options);
|
35
35
|
}
|
36
36
|
|
37
|
-
SinkResultType PhysicalReservoirSample::Sink(ExecutionContext &context,
|
38
|
-
|
39
|
-
auto &gstate =
|
37
|
+
SinkResultType PhysicalReservoirSample::Sink(ExecutionContext &context, DataChunk &chunk,
|
38
|
+
OperatorSinkInput &input) const {
|
39
|
+
auto &gstate = input.global_state.Cast<SampleGlobalSinkState>();
|
40
40
|
if (!gstate.sample) {
|
41
41
|
return SinkResultType::FINISHED;
|
42
42
|
}
|
@@ -44,24 +44,26 @@ SinkResultType PhysicalReservoirSample::Sink(ExecutionContext &context, GlobalSi
|
|
44
44
|
// the algorithm is adopted from the paper Weighted random sampling with a reservoir by Pavlos S. Efraimidis et al.
|
45
45
|
// note that the original algorithm is about weighted sampling; this is a simplified approach for uniform sampling
|
46
46
|
lock_guard<mutex> glock(gstate.lock);
|
47
|
-
gstate.sample->AddToReservoir(
|
47
|
+
gstate.sample->AddToReservoir(chunk);
|
48
48
|
return SinkResultType::NEED_MORE_INPUT;
|
49
49
|
}
|
50
50
|
|
51
51
|
//===--------------------------------------------------------------------===//
|
52
52
|
// Source
|
53
53
|
//===--------------------------------------------------------------------===//
|
54
|
-
|
55
|
-
|
54
|
+
SourceResultType PhysicalReservoirSample::GetData(ExecutionContext &context, DataChunk &chunk,
|
55
|
+
OperatorSourceInput &input) const {
|
56
56
|
auto &sink = this->sink_state->Cast<SampleGlobalSinkState>();
|
57
57
|
if (!sink.sample) {
|
58
|
-
return;
|
58
|
+
return SourceResultType::FINISHED;
|
59
59
|
}
|
60
60
|
auto sample_chunk = sink.sample->GetChunk();
|
61
61
|
if (!sample_chunk) {
|
62
|
-
return;
|
62
|
+
return SourceResultType::FINISHED;
|
63
63
|
}
|
64
64
|
chunk.Move(*sample_chunk);
|
65
|
+
|
66
|
+
return SourceResultType::HAVE_MORE_OUTPUT;
|
65
67
|
}
|
66
68
|
|
67
69
|
string PhysicalReservoirSample::ParamsToString() const {
|
@@ -19,8 +19,7 @@ void PhysicalReset::ResetExtensionVariable(ExecutionContext &context, DBConfig &
|
|
19
19
|
}
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
LocalSourceState &lstate) const {
|
22
|
+
SourceResultType PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
24
23
|
auto option = DBConfig::GetOptionByName(name);
|
25
24
|
if (!option) {
|
26
25
|
// check if this is an extra extension variable
|
@@ -30,7 +29,7 @@ void PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
30
29
|
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
31
30
|
}
|
32
31
|
ResetExtensionVariable(context, config, entry->second);
|
33
|
-
return;
|
32
|
+
return SourceResultType::FINISHED;
|
34
33
|
}
|
35
34
|
|
36
35
|
// Transform scope
|
@@ -63,6 +62,8 @@ void PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
63
62
|
default:
|
64
63
|
throw InternalException("Unsupported SetScope for variable");
|
65
64
|
}
|
65
|
+
|
66
|
+
return SourceResultType::FINISHED;
|
66
67
|
}
|
67
68
|
|
68
69
|
} // namespace duckdb
|
@@ -22,8 +22,7 @@ void PhysicalSet::SetExtensionVariable(ClientContext &context, ExtensionOption &
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
|
25
|
-
|
26
|
-
LocalSourceState &lstate) const {
|
25
|
+
SourceResultType PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
27
26
|
auto option = DBConfig::GetOptionByName(name);
|
28
27
|
if (!option) {
|
29
28
|
// check if this is an extra extension variable
|
@@ -33,7 +32,7 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
|
|
33
32
|
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
34
33
|
}
|
35
34
|
SetExtensionVariable(context.client, entry->second, name, scope, value);
|
36
|
-
return;
|
35
|
+
return SourceResultType::FINISHED;
|
37
36
|
}
|
38
37
|
SetScope variable_scope = scope;
|
39
38
|
if (variable_scope == SetScope::AUTOMATIC) {
|
@@ -45,7 +44,7 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
|
|
45
44
|
}
|
46
45
|
}
|
47
46
|
|
48
|
-
Value
|
47
|
+
Value input_val = value.CastAs(context.client, option->parameter_type);
|
49
48
|
switch (variable_scope) {
|
50
49
|
case SetScope::GLOBAL: {
|
51
50
|
if (!option->set_global) {
|
@@ -53,18 +52,20 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
|
|
53
52
|
}
|
54
53
|
auto &db = DatabaseInstance::GetDatabase(context.client);
|
55
54
|
auto &config = DBConfig::GetConfig(context.client);
|
56
|
-
config.SetOption(&db, *option,
|
55
|
+
config.SetOption(&db, *option, input_val);
|
57
56
|
break;
|
58
57
|
}
|
59
58
|
case SetScope::SESSION:
|
60
59
|
if (!option->set_local) {
|
61
60
|
throw CatalogException("option \"%s\" cannot be set locally", name);
|
62
61
|
}
|
63
|
-
option->set_local(context.client,
|
62
|
+
option->set_local(context.client, input_val);
|
64
63
|
break;
|
65
64
|
default:
|
66
65
|
throw InternalException("Unsupported SetScope for variable");
|
67
66
|
}
|
67
|
+
|
68
|
+
return SourceResultType::FINISHED;
|
68
69
|
}
|
69
70
|
|
70
71
|
} // namespace duckdb
|
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
SourceResultType PhysicalTransaction::GetData(ExecutionContext &context, DataChunk &chunk,
|
8
|
+
OperatorSourceInput &input) const {
|
9
9
|
auto &client = context.client;
|
10
10
|
|
11
11
|
auto type = info->type;
|
@@ -48,6 +48,8 @@ void PhysicalTransaction::GetData(ExecutionContext &context, DataChunk &chunk, G
|
|
48
48
|
default:
|
49
49
|
throw NotImplementedException("Unrecognized transaction type!");
|
50
50
|
}
|
51
|
+
|
52
|
+
return SourceResultType::FINISHED;
|
51
53
|
}
|
52
54
|
|
53
55
|
} // namespace duckdb
|