duckdb 0.8.1-dev96.0 → 0.8.1
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 +8 -8
- package/package.json +3 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +5 -4
- package/src/duckdb/extension/icu/icu-strptime.cpp +1 -1
- package/src/duckdb/extension/icu/third_party/icu/i18n/nfsubs.cpp +0 -2
- package/src/duckdb/extension/json/buffered_json_reader.cpp +23 -14
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +6 -6
- package/src/duckdb/extension/json/include/json_common.hpp +12 -2
- package/src/duckdb/extension/json/include/json_scan.hpp +5 -2
- package/src/duckdb/extension/json/json_functions/json_contains.cpp +5 -0
- package/src/duckdb/extension/json/json_functions/json_create.cpp +10 -10
- package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +5 -3
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +11 -11
- package/src/duckdb/extension/json/json_functions/read_json.cpp +2 -1
- package/src/duckdb/extension/json/json_functions.cpp +6 -3
- package/src/duckdb/extension/json/json_scan.cpp +43 -27
- package/src/duckdb/extension/parquet/column_reader.cpp +5 -1
- package/src/duckdb/extension/parquet/include/decode_utils.hpp +6 -0
- package/src/duckdb/extension/parquet/parquet-extension.cpp +26 -1
- package/src/duckdb/src/catalog/catalog.cpp +5 -17
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +7 -1
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +121 -0
- package/src/duckdb/src/catalog/catalog_search_path.cpp +49 -12
- package/src/duckdb/src/catalog/default/default_types.cpp +9 -84
- package/src/duckdb/src/common/adbc/adbc.cpp +118 -12
- package/src/duckdb/src/common/adbc/driver_manager.cpp +0 -20
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +11 -12
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +4 -3
- package/src/duckdb/src/common/exception.cpp +4 -1
- package/src/duckdb/src/common/exception_format_value.cpp +24 -15
- package/src/duckdb/src/common/multi_file_reader.cpp +3 -0
- package/src/duckdb/src/common/random_engine.cpp +1 -1
- package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +5 -4
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +44 -7
- package/src/duckdb/src/common/types/time.cpp +2 -8
- package/src/duckdb/src/common/types/timestamp.cpp +37 -1
- package/src/duckdb/src/common/types/value.cpp +1 -0
- package/src/duckdb/src/common/types.cpp +4 -0
- package/src/duckdb/src/core_functions/aggregate/algebraic/avg.cpp +30 -33
- package/src/duckdb/src/core_functions/aggregate/algebraic/covar.cpp +0 -4
- package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +30 -33
- package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +52 -65
- package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +48 -48
- package/src/duckdb/src/core_functions/aggregate/distributive/bitstring_agg.cpp +39 -40
- package/src/duckdb/src/core_functions/aggregate/distributive/bool.cpp +32 -32
- package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +34 -34
- package/src/duckdb/src/core_functions/aggregate/distributive/kurtosis.cpp +30 -31
- package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +88 -100
- package/src/duckdb/src/core_functions/aggregate/distributive/product.cpp +17 -17
- package/src/duckdb/src/core_functions/aggregate/distributive/skew.cpp +25 -27
- package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +37 -38
- package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +22 -22
- package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +44 -80
- package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +49 -51
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +104 -122
- package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +57 -93
- package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +22 -23
- package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +18 -19
- package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +16 -18
- package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +22 -25
- package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +19 -24
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +18 -23
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +14 -18
- package/src/duckdb/src/core_functions/function_list.cpp +1 -0
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +3 -0
- package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
- package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +23 -6
- package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/map/map_concat.cpp +3 -0
- package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +3 -3
- package/src/duckdb/src/execution/index/art/art.cpp +80 -7
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +20 -1
- package/src/duckdb/src/execution/index/art/leaf.cpp +11 -11
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +10 -0
- package/src/duckdb/src/execution/index/art/node.cpp +48 -35
- package/src/duckdb/src/execution/index/art/node16.cpp +3 -0
- package/src/duckdb/src/execution/index/art/node256.cpp +1 -0
- package/src/duckdb/src/execution/index/art/node4.cpp +3 -0
- package/src/duckdb/src/execution/index/art/node48.cpp +2 -0
- package/src/duckdb/src/execution/index/art/prefix.cpp +2 -0
- package/src/duckdb/src/execution/join_hashtable.cpp +2 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +26 -9
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +3 -6
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +1 -0
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +8 -3
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +0 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +29 -3
- package/src/duckdb/src/execution/reservoir_sample.cpp +18 -4
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +159 -21
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +67 -74
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +7 -7
- package/src/duckdb/src/function/cast/list_casts.cpp +2 -4
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +1 -1
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +6 -2
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
- package/src/duckdb/src/function/table/arrow.cpp +2 -2
- package/src/duckdb/src/function/table/checkpoint.cpp +3 -0
- package/src/duckdb/src/function/table/read_csv.cpp +15 -17
- package/src/duckdb/src/function/table/repeat.cpp +3 -0
- package/src/duckdb/src/function/table/repeat_row.cpp +8 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +4 -4
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +81 -25
- package/src/duckdb/src/function/table/table_scan.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +0 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +11 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +8 -2
- package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +97 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_converter.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_options.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/arrow/result_arrow_wrapper.hpp +0 -1
- package/src/duckdb/src/include/duckdb/common/bit_utils.hpp +16 -22
- package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/time.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +4 -14
- package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +92 -57
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +20 -24
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +36 -39
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +57 -53
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +8 -9
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +16 -18
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/sum_helpers.hpp +7 -8
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +10 -4
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +13 -3
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +9 -30
- package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +95 -0
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -2
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +142 -136
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
- package/src/duckdb/src/include/duckdb/optimizer/unnest_rewriter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +12 -3
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +0 -2
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +5 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +6 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/byte_reader.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +13 -13
- package/src/duckdb/src/include/duckdb/storage/index.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +0 -6
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +0 -2
- package/src/duckdb/src/main/attached_database.cpp +8 -0
- package/src/duckdb/src/main/capi/arrow-c.cpp +4 -4
- package/src/duckdb/src/main/capi/config-c.cpp +2 -5
- package/src/duckdb/src/main/client_context.cpp +4 -3
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/database.cpp +1 -0
- package/src/duckdb/src/main/database_manager.cpp +21 -0
- package/src/duckdb/src/main/query_result.cpp +6 -2
- package/src/duckdb/src/main/settings/settings.cpp +41 -6
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +27 -16
- package/src/duckdb/src/parallel/executor.cpp +38 -14
- package/src/duckdb/src/parallel/meta_pipeline.cpp +17 -3
- package/src/duckdb/src/parser/column_definition.cpp +5 -8
- package/src/duckdb/src/parser/parsed_data/create_info.cpp +0 -3
- package/src/duckdb/src/parser/parser.cpp +95 -35
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +1 -0
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +3 -0
- package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +0 -2
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +0 -3
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
- package/src/duckdb/src/parser/transformer.cpp +0 -2
- package/src/duckdb/src/planner/bind_context.cpp +3 -4
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +0 -2
- package/src/duckdb/src/planner/binder/expression/bind_positional_reference_expression.cpp +8 -3
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +31 -15
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +0 -27
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +18 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +0 -25
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -114
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +6 -1
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +5 -0
- package/src/duckdb/src/planner/bound_result_modifier.cpp +14 -0
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +6 -5
- package/src/duckdb/src/planner/expression/bound_default_expression.cpp +7 -1
- package/src/duckdb/src/planner/expression.cpp +3 -0
- package/src/duckdb/src/planner/expression_binder.cpp +3 -2
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +5 -4
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +14 -2
- package/src/duckdb/src/planner/planner.cpp +5 -15
- package/src/duckdb/src/storage/data_table.cpp +10 -8
- package/src/duckdb/src/storage/index.cpp +13 -0
- package/src/duckdb/src/storage/storage_manager.cpp +6 -0
- package/src/duckdb/src/storage/table/column_data.cpp +7 -3
- package/src/duckdb/src/storage/table/list_column_data.cpp +5 -4
- package/src/duckdb/src/storage/table/row_group.cpp +4 -3
- package/src/duckdb/src/storage/table/row_group_collection.cpp +6 -3
- package/src/duckdb/src/storage/table/standard_column_data.cpp +4 -3
- package/src/duckdb/src/storage/table/struct_column_data.cpp +4 -3
- package/src/duckdb/src/storage/wal_replay.cpp +4 -5
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +0 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +0 -14
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12828 -12956
- package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3 -0
- package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +4 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
- package/src/duckdb/ub_src_parser_transform_statement.cpp +0 -2
- package/test/extension.test.ts +11 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -46
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -27
@@ -32,25 +32,25 @@ struct StringAggBindData : public FunctionData {
|
|
32
32
|
|
33
33
|
struct StringAggFunction {
|
34
34
|
template <class STATE>
|
35
|
-
static void Initialize(STATE
|
36
|
-
state
|
37
|
-
state
|
38
|
-
state
|
35
|
+
static void Initialize(STATE &state) {
|
36
|
+
state.dataptr = nullptr;
|
37
|
+
state.alloc_size = 0;
|
38
|
+
state.size = 0;
|
39
39
|
}
|
40
40
|
|
41
41
|
template <class T, class STATE>
|
42
|
-
static void Finalize(
|
43
|
-
if (!state
|
44
|
-
|
42
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
43
|
+
if (!state.dataptr) {
|
44
|
+
finalize_data.ReturnNull();
|
45
45
|
} else {
|
46
|
-
target
|
46
|
+
target = StringVector::AddString(finalize_data.result, state.dataptr, state.size);
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
50
50
|
template <class STATE>
|
51
|
-
static void Destroy(
|
52
|
-
if (state
|
53
|
-
delete[] state
|
51
|
+
static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
|
52
|
+
if (state.dataptr) {
|
53
|
+
delete[] state.dataptr;
|
54
54
|
}
|
55
55
|
}
|
56
56
|
|
@@ -58,57 +58,56 @@ struct StringAggFunction {
|
|
58
58
|
return true;
|
59
59
|
}
|
60
60
|
|
61
|
-
static inline void PerformOperation(StringAggState
|
61
|
+
static inline void PerformOperation(StringAggState &state, const char *str, const char *sep, idx_t str_size,
|
62
62
|
idx_t sep_size) {
|
63
|
-
if (!state
|
63
|
+
if (!state.dataptr) {
|
64
64
|
// first iteration: allocate space for the string and copy it into the state
|
65
|
-
state
|
66
|
-
state
|
67
|
-
state
|
68
|
-
memcpy(state
|
65
|
+
state.alloc_size = MaxValue<idx_t>(8, NextPowerOfTwo(str_size));
|
66
|
+
state.dataptr = new char[state.alloc_size];
|
67
|
+
state.size = str_size;
|
68
|
+
memcpy(state.dataptr, str, str_size);
|
69
69
|
} else {
|
70
70
|
// subsequent iteration: first check if we have space to place the string and separator
|
71
|
-
idx_t required_size = state
|
72
|
-
if (required_size > state
|
71
|
+
idx_t required_size = state.size + str_size + sep_size;
|
72
|
+
if (required_size > state.alloc_size) {
|
73
73
|
// no space! allocate extra space
|
74
|
-
while (state
|
75
|
-
state
|
74
|
+
while (state.alloc_size < required_size) {
|
75
|
+
state.alloc_size *= 2;
|
76
76
|
}
|
77
|
-
auto new_data = new char[state
|
78
|
-
memcpy(new_data, state
|
79
|
-
delete[] state
|
80
|
-
state
|
77
|
+
auto new_data = new char[state.alloc_size];
|
78
|
+
memcpy(new_data, state.dataptr, state.size);
|
79
|
+
delete[] state.dataptr;
|
80
|
+
state.dataptr = new_data;
|
81
81
|
}
|
82
82
|
// copy the separator
|
83
|
-
memcpy(state
|
84
|
-
state
|
83
|
+
memcpy(state.dataptr + state.size, sep, sep_size);
|
84
|
+
state.size += sep_size;
|
85
85
|
// copy the string
|
86
|
-
memcpy(state
|
87
|
-
state
|
86
|
+
memcpy(state.dataptr + state.size, str, str_size);
|
87
|
+
state.size += str_size;
|
88
88
|
}
|
89
89
|
}
|
90
90
|
|
91
|
-
static inline void PerformOperation(StringAggState
|
91
|
+
static inline void PerformOperation(StringAggState &state, string_t str, optional_ptr<FunctionData> data_p) {
|
92
92
|
auto &data = data_p->Cast<StringAggBindData>();
|
93
93
|
PerformOperation(state, str.GetData(), data.sep.c_str(), str.GetSize(), data.sep.size());
|
94
94
|
}
|
95
95
|
|
96
96
|
template <class INPUT_TYPE, class STATE, class OP>
|
97
|
-
static void Operation(STATE
|
98
|
-
|
99
|
-
PerformOperation(state, str_data[str_idx], aggr_input_data.bind_data);
|
97
|
+
static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
|
98
|
+
PerformOperation(state, input, unary_input.input.bind_data);
|
100
99
|
}
|
101
100
|
|
102
101
|
template <class INPUT_TYPE, class STATE, class OP>
|
103
|
-
static void ConstantOperation(STATE
|
104
|
-
|
102
|
+
static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
|
103
|
+
idx_t count) {
|
105
104
|
for (idx_t i = 0; i < count; i++) {
|
106
|
-
Operation<INPUT_TYPE, STATE, OP>(state,
|
105
|
+
Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
|
107
106
|
}
|
108
107
|
}
|
109
108
|
|
110
109
|
template <class STATE, class OP>
|
111
|
-
static void Combine(const STATE &source, STATE
|
110
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &aggr_input_data) {
|
112
111
|
if (!source.dataptr) {
|
113
112
|
// source is not set: skip combining
|
114
113
|
return;
|
@@ -148,7 +147,7 @@ static void StringAggSerialize(FieldWriter &writer, const FunctionData *bind_dat
|
|
148
147
|
writer.WriteString(bind_data.sep);
|
149
148
|
}
|
150
149
|
|
151
|
-
unique_ptr<FunctionData> StringAggDeserialize(
|
150
|
+
unique_ptr<FunctionData> StringAggDeserialize(PlanDeserializationState &state, FieldReader &reader,
|
152
151
|
AggregateFunction &bound_function) {
|
153
152
|
auto sep = reader.ReadRequired<string>();
|
154
153
|
return make_uniq<StringAggBindData>(std::move(sep));
|
@@ -8,37 +8,37 @@ namespace duckdb {
|
|
8
8
|
|
9
9
|
struct SumSetOperation {
|
10
10
|
template <class STATE>
|
11
|
-
static void Initialize(STATE
|
12
|
-
state
|
11
|
+
static void Initialize(STATE &state) {
|
12
|
+
state.Initialize();
|
13
13
|
}
|
14
14
|
template <class STATE>
|
15
|
-
static void Combine(const STATE &source, STATE
|
16
|
-
target
|
15
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
|
16
|
+
target.Combine(source);
|
17
17
|
}
|
18
18
|
template <class STATE>
|
19
|
-
static void AddValues(STATE
|
20
|
-
state
|
19
|
+
static void AddValues(STATE &state, idx_t count) {
|
20
|
+
state.isset = true;
|
21
21
|
}
|
22
22
|
};
|
23
23
|
|
24
24
|
struct IntegerSumOperation : public BaseSumOperation<SumSetOperation, RegularAdd> {
|
25
25
|
template <class T, class STATE>
|
26
|
-
static void Finalize(
|
27
|
-
if (!state
|
28
|
-
|
26
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
27
|
+
if (!state.isset) {
|
28
|
+
finalize_data.ReturnNull();
|
29
29
|
} else {
|
30
|
-
target
|
30
|
+
target = Hugeint::Convert(state.value);
|
31
31
|
}
|
32
32
|
}
|
33
33
|
};
|
34
34
|
|
35
35
|
struct SumToHugeintOperation : public BaseSumOperation<SumSetOperation, HugeintAdd> {
|
36
36
|
template <class T, class STATE>
|
37
|
-
static void Finalize(
|
38
|
-
if (!state
|
39
|
-
|
37
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
38
|
+
if (!state.isset) {
|
39
|
+
finalize_data.ReturnNull();
|
40
40
|
} else {
|
41
|
-
target
|
41
|
+
target = state.value;
|
42
42
|
}
|
43
43
|
}
|
44
44
|
};
|
@@ -46,11 +46,11 @@ struct SumToHugeintOperation : public BaseSumOperation<SumSetOperation, HugeintA
|
|
46
46
|
template <class ADD_OPERATOR>
|
47
47
|
struct DoubleSumOperation : public BaseSumOperation<SumSetOperation, ADD_OPERATOR> {
|
48
48
|
template <class T, class STATE>
|
49
|
-
static void Finalize(
|
50
|
-
if (!state
|
51
|
-
|
49
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
50
|
+
if (!state.isset) {
|
51
|
+
finalize_data.ReturnNull();
|
52
52
|
} else {
|
53
|
-
target
|
53
|
+
target = state.value;
|
54
54
|
}
|
55
55
|
}
|
56
56
|
};
|
@@ -60,11 +60,11 @@ using KahanSumOperation = DoubleSumOperation<KahanAdd>;
|
|
60
60
|
|
61
61
|
struct HugeintSumOperation : public BaseSumOperation<SumSetOperation, RegularAdd> {
|
62
62
|
template <class T, class STATE>
|
63
|
-
static void Finalize(
|
64
|
-
if (!state
|
65
|
-
|
63
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
64
|
+
if (!state.isset) {
|
65
|
+
finalize_data.ReturnNull();
|
66
66
|
} else {
|
67
|
-
target
|
67
|
+
target = state.value;
|
68
68
|
}
|
69
69
|
}
|
70
70
|
};
|
@@ -42,7 +42,7 @@ struct ApproximateQuantileBindData : public FunctionData {
|
|
42
42
|
writer.WriteList<float>(bind_data.quantiles);
|
43
43
|
}
|
44
44
|
|
45
|
-
static unique_ptr<FunctionData> Deserialize(
|
45
|
+
static unique_ptr<FunctionData> Deserialize(PlanDeserializationState &state, FieldReader &reader,
|
46
46
|
AggregateFunction &bound_function) {
|
47
47
|
auto quantiles = reader.ReadRequiredList<float>();
|
48
48
|
return make_uniq<ApproximateQuantileBindData>(std::move(quantiles));
|
@@ -55,49 +55,49 @@ struct ApproxQuantileOperation {
|
|
55
55
|
using SAVE_TYPE = duckdb_tdigest::Value;
|
56
56
|
|
57
57
|
template <class STATE>
|
58
|
-
static void Initialize(STATE
|
59
|
-
state
|
60
|
-
state
|
58
|
+
static void Initialize(STATE &state) {
|
59
|
+
state.pos = 0;
|
60
|
+
state.h = nullptr;
|
61
61
|
}
|
62
62
|
|
63
63
|
template <class INPUT_TYPE, class STATE, class OP>
|
64
|
-
static void ConstantOperation(STATE
|
65
|
-
|
64
|
+
static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
|
65
|
+
idx_t count) {
|
66
66
|
for (idx_t i = 0; i < count; i++) {
|
67
|
-
Operation<INPUT_TYPE, STATE, OP>(state,
|
67
|
+
Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
|
68
68
|
}
|
69
69
|
}
|
70
70
|
|
71
71
|
template <class INPUT_TYPE, class STATE, class OP>
|
72
|
-
static void Operation(STATE
|
73
|
-
auto val = Cast::template Operation<INPUT_TYPE, SAVE_TYPE>(
|
72
|
+
static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
|
73
|
+
auto val = Cast::template Operation<INPUT_TYPE, SAVE_TYPE>(input);
|
74
74
|
if (!Value::DoubleIsFinite(val)) {
|
75
75
|
return;
|
76
76
|
}
|
77
|
-
if (!state
|
78
|
-
state
|
77
|
+
if (!state.h) {
|
78
|
+
state.h = new duckdb_tdigest::TDigest(100);
|
79
79
|
}
|
80
|
-
state
|
81
|
-
state
|
80
|
+
state.h->add(val);
|
81
|
+
state.pos++;
|
82
82
|
}
|
83
83
|
|
84
84
|
template <class STATE, class OP>
|
85
|
-
static void Combine(const STATE &source, STATE
|
85
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
|
86
86
|
if (source.pos == 0) {
|
87
87
|
return;
|
88
88
|
}
|
89
89
|
D_ASSERT(source.h);
|
90
|
-
if (!target
|
91
|
-
target
|
90
|
+
if (!target.h) {
|
91
|
+
target.h = new duckdb_tdigest::TDigest(100);
|
92
92
|
}
|
93
|
-
target
|
94
|
-
target
|
93
|
+
target.h->merge(source.h);
|
94
|
+
target.pos += source.pos;
|
95
95
|
}
|
96
96
|
|
97
97
|
template <class STATE>
|
98
|
-
static void Destroy(
|
99
|
-
if (state
|
100
|
-
delete state
|
98
|
+
static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
|
99
|
+
if (state.h) {
|
100
|
+
delete state.h;
|
101
101
|
}
|
102
102
|
}
|
103
103
|
|
@@ -107,21 +107,18 @@ struct ApproxQuantileOperation {
|
|
107
107
|
};
|
108
108
|
|
109
109
|
struct ApproxQuantileScalarOperation : public ApproxQuantileOperation {
|
110
|
-
|
111
110
|
template <class TARGET_TYPE, class STATE>
|
112
|
-
static void Finalize(
|
113
|
-
|
114
|
-
|
115
|
-
if (state->pos == 0) {
|
116
|
-
mask.SetInvalid(idx);
|
111
|
+
static void Finalize(STATE &state, TARGET_TYPE &target, AggregateFinalizeData &finalize_data) {
|
112
|
+
if (state.pos == 0) {
|
113
|
+
finalize_data.ReturnNull();
|
117
114
|
return;
|
118
115
|
}
|
119
|
-
D_ASSERT(state
|
120
|
-
D_ASSERT(
|
121
|
-
state
|
122
|
-
auto &bind_data =
|
116
|
+
D_ASSERT(state.h);
|
117
|
+
D_ASSERT(finalize_data.input.bind_data);
|
118
|
+
state.h->compress();
|
119
|
+
auto &bind_data = finalize_data.input.bind_data->template Cast<ApproximateQuantileBindData>();
|
123
120
|
D_ASSERT(bind_data.quantiles.size() == 1);
|
124
|
-
target
|
121
|
+
target = Cast::template Operation<SAVE_TYPE, TARGET_TYPE>(state.h->quantile(bind_data.quantiles[0]));
|
125
122
|
}
|
126
123
|
};
|
127
124
|
|
@@ -212,65 +209,32 @@ template <class CHILD_TYPE>
|
|
212
209
|
struct ApproxQuantileListOperation : public ApproxQuantileOperation {
|
213
210
|
|
214
211
|
template <class RESULT_TYPE, class STATE>
|
215
|
-
static void Finalize(
|
216
|
-
|
217
|
-
|
218
|
-
mask.SetInvalid(idx);
|
212
|
+
static void Finalize(STATE &state, RESULT_TYPE &target, AggregateFinalizeData &finalize_data) {
|
213
|
+
if (state.pos == 0) {
|
214
|
+
finalize_data.ReturnNull();
|
219
215
|
return;
|
220
216
|
}
|
221
217
|
|
222
|
-
D_ASSERT(
|
223
|
-
auto &bind_data =
|
218
|
+
D_ASSERT(finalize_data.input.bind_data);
|
219
|
+
auto &bind_data = finalize_data.input.bind_data->template Cast<ApproximateQuantileBindData>();
|
224
220
|
|
225
|
-
auto &result = ListVector::GetEntry(
|
226
|
-
auto ridx = ListVector::GetListSize(
|
227
|
-
ListVector::Reserve(
|
221
|
+
auto &result = ListVector::GetEntry(finalize_data.result);
|
222
|
+
auto ridx = ListVector::GetListSize(finalize_data.result);
|
223
|
+
ListVector::Reserve(finalize_data.result, ridx + bind_data.quantiles.size());
|
228
224
|
auto rdata = FlatVector::GetData<CHILD_TYPE>(result);
|
229
225
|
|
230
|
-
D_ASSERT(state
|
231
|
-
state
|
226
|
+
D_ASSERT(state.h);
|
227
|
+
state.h->compress();
|
232
228
|
|
233
|
-
auto &entry = target
|
229
|
+
auto &entry = target;
|
234
230
|
entry.offset = ridx;
|
235
231
|
entry.length = bind_data.quantiles.size();
|
236
232
|
for (size_t q = 0; q < entry.length; ++q) {
|
237
233
|
const auto &quantile = bind_data.quantiles[q];
|
238
|
-
rdata[ridx + q] = Cast::template Operation<SAVE_TYPE, CHILD_TYPE>(state
|
239
|
-
}
|
240
|
-
|
241
|
-
ListVector::SetListSize(result_list, entry.offset + entry.length);
|
242
|
-
}
|
243
|
-
|
244
|
-
template <class STATE_TYPE, class RESULT_TYPE>
|
245
|
-
static void FinalizeList(Vector &states, AggregateInputData &aggr_input_data, Vector &result, idx_t count, // NOLINT
|
246
|
-
idx_t offset) {
|
247
|
-
D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
|
248
|
-
|
249
|
-
D_ASSERT(aggr_input_data.bind_data);
|
250
|
-
auto &bind_data = aggr_input_data.bind_data->template Cast<ApproximateQuantileBindData>();
|
251
|
-
|
252
|
-
if (states.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
253
|
-
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
254
|
-
ListVector::Reserve(result, bind_data.quantiles.size());
|
255
|
-
|
256
|
-
auto sdata = ConstantVector::GetData<STATE_TYPE *>(states);
|
257
|
-
auto rdata = ConstantVector::GetData<RESULT_TYPE>(result);
|
258
|
-
auto &mask = ConstantVector::Validity(result);
|
259
|
-
Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[0], rdata, mask, 0);
|
260
|
-
} else {
|
261
|
-
D_ASSERT(states.GetVectorType() == VectorType::FLAT_VECTOR);
|
262
|
-
result.SetVectorType(VectorType::FLAT_VECTOR);
|
263
|
-
ListVector::Reserve(result, (offset + count) * bind_data.quantiles.size());
|
264
|
-
|
265
|
-
auto sdata = FlatVector::GetData<STATE_TYPE *>(states);
|
266
|
-
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
267
|
-
auto &mask = FlatVector::Validity(result);
|
268
|
-
for (idx_t i = 0; i < count; i++) {
|
269
|
-
Finalize<RESULT_TYPE, STATE_TYPE>(result, aggr_input_data, sdata[i], rdata, mask, i + offset);
|
270
|
-
}
|
234
|
+
rdata[ridx + q] = Cast::template Operation<SAVE_TYPE, CHILD_TYPE>(state.h->quantile(quantile));
|
271
235
|
}
|
272
236
|
|
273
|
-
result.
|
237
|
+
ListVector::SetListSize(finalize_data.result, entry.offset + entry.length);
|
274
238
|
}
|
275
239
|
};
|
276
240
|
|
@@ -280,8 +244,8 @@ static AggregateFunction ApproxQuantileListAggregate(const LogicalType &input_ty
|
|
280
244
|
return AggregateFunction(
|
281
245
|
{input_type}, result_type, AggregateFunction::StateSize<STATE>, AggregateFunction::StateInitialize<STATE, OP>,
|
282
246
|
AggregateFunction::UnaryScatterUpdate<STATE, INPUT_TYPE, OP>, AggregateFunction::StateCombine<STATE, OP>,
|
283
|
-
|
284
|
-
AggregateFunction::StateDestroy<STATE, OP>);
|
247
|
+
AggregateFunction::StateFinalize<STATE, RESULT_TYPE, OP>, AggregateFunction::UnaryUpdate<STATE, INPUT_TYPE, OP>,
|
248
|
+
nullptr, AggregateFunction::StateDestroy<STATE, OP>);
|
285
249
|
}
|
286
250
|
|
287
251
|
template <typename INPUT_TYPE, typename SAVE_TYPE>
|
@@ -150,126 +150,124 @@ struct ModeAssignmentString {
|
|
150
150
|
template <typename KEY_TYPE, typename ASSIGN_OP>
|
151
151
|
struct ModeFunction {
|
152
152
|
template <class STATE>
|
153
|
-
static void Initialize(STATE
|
154
|
-
state
|
153
|
+
static void Initialize(STATE &state) {
|
154
|
+
state.Initialize();
|
155
155
|
}
|
156
156
|
|
157
157
|
template <class INPUT_TYPE, class STATE, class OP>
|
158
|
-
static void Operation(STATE
|
159
|
-
if (!state
|
160
|
-
state
|
158
|
+
static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &) {
|
159
|
+
if (!state.frequency_map) {
|
160
|
+
state.frequency_map = new typename STATE::Counts();
|
161
161
|
}
|
162
|
-
auto key = KEY_TYPE(input
|
163
|
-
auto &i = (*state
|
162
|
+
auto key = KEY_TYPE(input);
|
163
|
+
auto &i = (*state.frequency_map)[key];
|
164
164
|
i.count++;
|
165
|
-
i.first_row = MinValue<idx_t>(i.first_row, state
|
166
|
-
state
|
165
|
+
i.first_row = MinValue<idx_t>(i.first_row, state.count);
|
166
|
+
state.count++;
|
167
167
|
}
|
168
168
|
|
169
169
|
template <class STATE, class OP>
|
170
|
-
static void Combine(const STATE &source, STATE
|
170
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
|
171
171
|
if (!source.frequency_map) {
|
172
172
|
return;
|
173
173
|
}
|
174
|
-
if (!target
|
174
|
+
if (!target.frequency_map) {
|
175
175
|
// Copy - don't destroy! Otherwise windowing will break.
|
176
|
-
target
|
176
|
+
target.frequency_map = new typename STATE::Counts(*source.frequency_map);
|
177
177
|
return;
|
178
178
|
}
|
179
179
|
for (auto &val : *source.frequency_map) {
|
180
|
-
auto &i = (*target
|
180
|
+
auto &i = (*target.frequency_map)[val.first];
|
181
181
|
i.count += val.second.count;
|
182
182
|
i.first_row = MinValue(i.first_row, val.second.first_row);
|
183
183
|
}
|
184
|
-
target
|
184
|
+
target.count += source.count;
|
185
185
|
}
|
186
186
|
|
187
|
-
template <class
|
188
|
-
static void Finalize(
|
189
|
-
|
190
|
-
|
191
|
-
mask.SetInvalid(idx);
|
187
|
+
template <class T, class STATE>
|
188
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
189
|
+
if (!state.frequency_map) {
|
190
|
+
finalize_data.ReturnNull();
|
192
191
|
return;
|
193
192
|
}
|
194
|
-
auto highest_frequency = state
|
195
|
-
if (highest_frequency != state
|
196
|
-
target
|
193
|
+
auto highest_frequency = state.Scan();
|
194
|
+
if (highest_frequency != state.frequency_map->end()) {
|
195
|
+
target = ASSIGN_OP::template Assign<T, T>(finalize_data.result, highest_frequency->first);
|
197
196
|
} else {
|
198
|
-
|
197
|
+
finalize_data.ReturnNull();
|
199
198
|
}
|
200
199
|
}
|
201
200
|
template <class INPUT_TYPE, class STATE, class OP>
|
202
|
-
static void ConstantOperation(STATE
|
203
|
-
|
204
|
-
|
205
|
-
state->frequency_map = new typename STATE::Counts();
|
201
|
+
static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &, idx_t count) {
|
202
|
+
if (!state.frequency_map) {
|
203
|
+
state.frequency_map = new typename STATE::Counts();
|
206
204
|
}
|
207
|
-
auto key = KEY_TYPE(input
|
208
|
-
auto &i = (*state
|
205
|
+
auto key = KEY_TYPE(input);
|
206
|
+
auto &i = (*state.frequency_map)[key];
|
209
207
|
i.count += count;
|
210
|
-
i.first_row = MinValue<idx_t>(i.first_row, state
|
211
|
-
state
|
208
|
+
i.first_row = MinValue<idx_t>(i.first_row, state.count);
|
209
|
+
state.count += count;
|
212
210
|
}
|
213
211
|
|
214
212
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
|
215
213
|
static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
|
216
|
-
AggregateInputData &, STATE
|
214
|
+
AggregateInputData &, STATE &state, const FrameBounds &frame, const FrameBounds &prev,
|
217
215
|
Vector &result, idx_t rid, idx_t bias) {
|
218
216
|
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
219
217
|
auto &rmask = FlatVector::Validity(result);
|
220
218
|
|
221
219
|
ModeIncluded included(fmask, dmask, bias);
|
222
220
|
|
223
|
-
if (!state
|
224
|
-
state
|
221
|
+
if (!state.frequency_map) {
|
222
|
+
state.frequency_map = new typename STATE::Counts;
|
225
223
|
}
|
226
224
|
const double tau = .25;
|
227
|
-
if (state
|
228
|
-
state
|
225
|
+
if (state.nonzero <= tau * state.frequency_map->size()) {
|
226
|
+
state.Reset();
|
229
227
|
// for f ∈ F do
|
230
228
|
for (auto f = frame.first; f < frame.second; ++f) {
|
231
229
|
if (included(f)) {
|
232
|
-
state
|
230
|
+
state.ModeAdd(KEY_TYPE(data[f]), f);
|
233
231
|
}
|
234
232
|
}
|
235
233
|
} else {
|
236
234
|
// for f ∈ P \ F do
|
237
235
|
for (auto p = prev.first; p < frame.first; ++p) {
|
238
236
|
if (included(p)) {
|
239
|
-
state
|
237
|
+
state.ModeRm(KEY_TYPE(data[p]), p);
|
240
238
|
}
|
241
239
|
}
|
242
240
|
for (auto p = frame.second; p < prev.second; ++p) {
|
243
241
|
if (included(p)) {
|
244
|
-
state
|
242
|
+
state.ModeRm(KEY_TYPE(data[p]), p);
|
245
243
|
}
|
246
244
|
}
|
247
245
|
|
248
246
|
// for f ∈ F \ P do
|
249
247
|
for (auto f = frame.first; f < prev.first; ++f) {
|
250
248
|
if (included(f)) {
|
251
|
-
state
|
249
|
+
state.ModeAdd(KEY_TYPE(data[f]), f);
|
252
250
|
}
|
253
251
|
}
|
254
252
|
for (auto f = prev.second; f < frame.second; ++f) {
|
255
253
|
if (included(f)) {
|
256
|
-
state
|
254
|
+
state.ModeAdd(KEY_TYPE(data[f]), f);
|
257
255
|
}
|
258
256
|
}
|
259
257
|
}
|
260
258
|
|
261
|
-
if (!state
|
259
|
+
if (!state.valid) {
|
262
260
|
// Rescan
|
263
|
-
auto highest_frequency = state
|
264
|
-
if (highest_frequency != state
|
265
|
-
*(state
|
266
|
-
state
|
267
|
-
state
|
261
|
+
auto highest_frequency = state.Scan();
|
262
|
+
if (highest_frequency != state.frequency_map->end()) {
|
263
|
+
*(state.mode) = highest_frequency->first;
|
264
|
+
state.count = highest_frequency->second.count;
|
265
|
+
state.valid = (state.count > 0);
|
268
266
|
}
|
269
267
|
}
|
270
268
|
|
271
|
-
if (state
|
272
|
-
rdata[rid] = ASSIGN_OP::template Assign<INPUT_TYPE, RESULT_TYPE>(result, *state
|
269
|
+
if (state.valid) {
|
270
|
+
rdata[rid] = ASSIGN_OP::template Assign<INPUT_TYPE, RESULT_TYPE>(result, *state.mode);
|
273
271
|
} else {
|
274
272
|
rmask.Set(rid, false);
|
275
273
|
}
|
@@ -280,8 +278,8 @@ struct ModeFunction {
|
|
280
278
|
}
|
281
279
|
|
282
280
|
template <class STATE>
|
283
|
-
static void Destroy(
|
284
|
-
state
|
281
|
+
static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
|
282
|
+
state.Destroy();
|
285
283
|
}
|
286
284
|
};
|
287
285
|
|