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
@@ -16,30 +16,29 @@ struct RegrSState {
|
|
16
16
|
|
17
17
|
struct RegrBaseOperation {
|
18
18
|
template <class STATE>
|
19
|
-
static void Initialize(STATE
|
20
|
-
RegrCountFunction::Initialize<size_t>(
|
21
|
-
STDDevBaseOperation::Initialize<StddevState>(
|
19
|
+
static void Initialize(STATE &state) {
|
20
|
+
RegrCountFunction::Initialize<size_t>(state.count);
|
21
|
+
STDDevBaseOperation::Initialize<StddevState>(state.var_pop);
|
22
22
|
}
|
23
23
|
|
24
24
|
template <class STATE, class OP>
|
25
|
-
static void Combine(const STATE &source, STATE
|
26
|
-
RegrCountFunction::Combine<size_t, OP>(source.count,
|
27
|
-
STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop,
|
25
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &aggr_input_data) {
|
26
|
+
RegrCountFunction::Combine<size_t, OP>(source.count, target.count, aggr_input_data);
|
27
|
+
STDDevBaseOperation::Combine<StddevState, OP>(source.var_pop, target.var_pop, aggr_input_data);
|
28
28
|
}
|
29
29
|
|
30
30
|
template <class T, class STATE>
|
31
|
-
static void Finalize(
|
32
|
-
|
33
|
-
|
34
|
-
mask.SetInvalid(idx);
|
31
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
32
|
+
if (state.var_pop.count == 0) {
|
33
|
+
finalize_data.ReturnNull();
|
35
34
|
return;
|
36
35
|
}
|
37
|
-
auto var_pop = state
|
36
|
+
auto var_pop = state.var_pop.count > 1 ? (state.var_pop.dsquared / state.var_pop.count) : 0;
|
38
37
|
if (!Value::DoubleIsFinite(var_pop)) {
|
39
38
|
throw OutOfRangeException("VARPOP is out of range!");
|
40
39
|
}
|
41
|
-
RegrCountFunction::Finalize<T, size_t>(
|
42
|
-
target
|
40
|
+
RegrCountFunction::Finalize<T, size_t>(state.count, target, finalize_data);
|
41
|
+
target *= var_pop;
|
43
42
|
}
|
44
43
|
|
45
44
|
static bool IgnoreNull() {
|
@@ -49,21 +48,17 @@ struct RegrBaseOperation {
|
|
49
48
|
|
50
49
|
struct RegrSXXOperation : RegrBaseOperation {
|
51
50
|
template <class A_TYPE, class B_TYPE, class STATE, class OP>
|
52
|
-
static void Operation(STATE
|
53
|
-
|
54
|
-
|
55
|
-
amask, yidx, xidx);
|
56
|
-
STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, aggr_input_data, y_data, bmask, yidx);
|
51
|
+
static void Operation(STATE &state, const A_TYPE &x, const B_TYPE &y, AggregateBinaryInput &idata) {
|
52
|
+
RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(state.count, x, y, idata);
|
53
|
+
STDDevBaseOperation::Execute<A_TYPE, StddevState>(state.var_pop, y);
|
57
54
|
}
|
58
55
|
};
|
59
56
|
|
60
57
|
struct RegrSYYOperation : RegrBaseOperation {
|
61
58
|
template <class A_TYPE, class B_TYPE, class STATE, class OP>
|
62
|
-
static void Operation(STATE
|
63
|
-
|
64
|
-
|
65
|
-
amask, yidx, xidx);
|
66
|
-
STDDevBaseOperation::Operation<A_TYPE, StddevState, OP>(&state->var_pop, aggr_input_data, x_data, bmask, xidx);
|
59
|
+
static void Operation(STATE &state, const A_TYPE &x, const B_TYPE &y, AggregateBinaryInput &idata) {
|
60
|
+
RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(state.count, x, y, idata);
|
61
|
+
STDDevBaseOperation::Execute<A_TYPE, StddevState>(state.var_pop, x);
|
67
62
|
}
|
68
63
|
};
|
69
64
|
|
@@ -14,33 +14,29 @@ struct RegrSXyState {
|
|
14
14
|
|
15
15
|
struct RegrSXYOperation {
|
16
16
|
template <class STATE>
|
17
|
-
static void Initialize(STATE
|
18
|
-
RegrCountFunction::Initialize<size_t>(
|
19
|
-
CovarOperation::Initialize<CovarState>(
|
17
|
+
static void Initialize(STATE &state) {
|
18
|
+
RegrCountFunction::Initialize<size_t>(state.count);
|
19
|
+
CovarOperation::Initialize<CovarState>(state.cov_pop);
|
20
20
|
}
|
21
21
|
|
22
22
|
template <class A_TYPE, class B_TYPE, class STATE, class OP>
|
23
|
-
static void Operation(STATE
|
24
|
-
|
25
|
-
|
26
|
-
amask, yidx, xidx);
|
27
|
-
CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(&state->cov_pop, aggr_input_data, x_data, y_data,
|
28
|
-
amask, bmask, xidx, yidx);
|
23
|
+
static void Operation(STATE &state, const A_TYPE &x, const B_TYPE &y, AggregateBinaryInput &idata) {
|
24
|
+
RegrCountFunction::Operation<A_TYPE, B_TYPE, size_t, OP>(state.count, x, y, idata);
|
25
|
+
CovarOperation::Operation<A_TYPE, B_TYPE, CovarState, OP>(state.cov_pop, x, y, idata);
|
29
26
|
}
|
30
27
|
|
31
28
|
template <class STATE, class OP>
|
32
|
-
static void Combine(const STATE &source, STATE
|
33
|
-
CovarOperation::Combine<CovarState, OP>(source.cov_pop,
|
34
|
-
RegrCountFunction::Combine<size_t, OP>(source.count,
|
29
|
+
static void Combine(const STATE &source, STATE &target, AggregateInputData &aggr_input_data) {
|
30
|
+
CovarOperation::Combine<CovarState, OP>(source.cov_pop, target.cov_pop, aggr_input_data);
|
31
|
+
RegrCountFunction::Combine<size_t, OP>(source.count, target.count, aggr_input_data);
|
35
32
|
}
|
36
33
|
|
37
34
|
template <class T, class STATE>
|
38
|
-
static void Finalize(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
target[idx] *= cov_pop;
|
35
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
36
|
+
CovarPopOperation::Finalize<T, CovarState>(state.cov_pop, target, finalize_data);
|
37
|
+
auto cov_pop = target;
|
38
|
+
RegrCountFunction::Finalize<T, size_t>(state.count, target, finalize_data);
|
39
|
+
target *= cov_pop;
|
44
40
|
}
|
45
41
|
|
46
42
|
static bool IgnoreNull() {
|
@@ -169,6 +169,7 @@ static StaticFunctionDefinition internal_functions[] = {
|
|
169
169
|
DUCKDB_SCALAR_FUNCTION_SET(HexFun),
|
170
170
|
DUCKDB_AGGREGATE_FUNCTION_SET(HistogramFun),
|
171
171
|
DUCKDB_SCALAR_FUNCTION_SET(HoursFun),
|
172
|
+
DUCKDB_SCALAR_FUNCTION(InSearchPathFun),
|
172
173
|
DUCKDB_SCALAR_FUNCTION(InstrFun),
|
173
174
|
DUCKDB_SCALAR_FUNCTION_SET(IsFiniteFun),
|
174
175
|
DUCKDB_SCALAR_FUNCTION_SET(IsInfiniteFun),
|
@@ -1377,7 +1377,7 @@ struct StructDatePart {
|
|
1377
1377
|
writer.WriteList<DatePartSpecifier>(info.part_codes);
|
1378
1378
|
}
|
1379
1379
|
|
1380
|
-
static unique_ptr<FunctionData> DeserializeFunction(
|
1380
|
+
static unique_ptr<FunctionData> DeserializeFunction(PlanDeserializationState &state, FieldReader &reader,
|
1381
1381
|
ScalarFunction &bound_function) {
|
1382
1382
|
auto stype = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
|
1383
1383
|
auto part_codes = reader.ReadRequiredList<DatePartSpecifier>();
|
@@ -47,6 +47,9 @@ struct MakeTimeOperator {
|
|
47
47
|
static RESULT_TYPE Operation(HH hh, MM mm, SS ss) {
|
48
48
|
int64_t secs = ss;
|
49
49
|
int64_t micros = std::round((ss - secs) * Interval::MICROS_PER_SEC);
|
50
|
+
if (!Time::IsValidTime(hh, mm, secs, micros)) {
|
51
|
+
throw ConversionException("Time out of range: %d:%d:%d.%d", hh, mm, secs, micros);
|
52
|
+
}
|
50
53
|
return Time::FromTime(hh, mm, secs, micros);
|
51
54
|
}
|
52
55
|
};
|
@@ -49,6 +49,16 @@ static void CurrentSchemasFunction(DataChunk &input, ExpressionState &state, Vec
|
|
49
49
|
result.Reference(val);
|
50
50
|
}
|
51
51
|
|
52
|
+
// in_search_path
|
53
|
+
static void InSearchPathFunction(DataChunk &input, ExpressionState &state, Vector &result) {
|
54
|
+
auto &context = state.GetContext();
|
55
|
+
auto &search_path = ClientData::Get(context).catalog_search_path;
|
56
|
+
BinaryExecutor::Execute<string_t, string_t, bool>(
|
57
|
+
input.data[0], input.data[1], result, input.size(), [&](string_t db_name, string_t schema_name) {
|
58
|
+
return search_path->SchemaInSearchPath(context, db_name.GetString(), schema_name.GetString());
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
52
62
|
// txid_current
|
53
63
|
static void TransactionIdCurrent(DataChunk &input, ExpressionState &state, Vector &result) {
|
54
64
|
auto &context = state.GetContext();
|
@@ -83,6 +93,10 @@ ScalarFunction CurrentSchemasFun::GetFunction() {
|
|
83
93
|
return ScalarFunction({LogicalType::BOOLEAN}, varchar_list_type, CurrentSchemasFunction);
|
84
94
|
}
|
85
95
|
|
96
|
+
ScalarFunction InSearchPathFun::GetFunction() {
|
97
|
+
return ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BOOLEAN, InSearchPathFunction);
|
98
|
+
}
|
99
|
+
|
86
100
|
ScalarFunction CurrentTransactionIdFun::GetFunction() {
|
87
101
|
return ScalarFunction({}, LogicalType::BIGINT, TransactionIdCurrent);
|
88
102
|
}
|
@@ -28,7 +28,7 @@ template <typename INPUT_TYPE, typename INDEX_TYPE>
|
|
28
28
|
bool ClampIndex(INDEX_TYPE &index, const INPUT_TYPE &value) {
|
29
29
|
const auto length = ValueLength<INPUT_TYPE, INDEX_TYPE>(value);
|
30
30
|
if (index < 0) {
|
31
|
-
if (
|
31
|
+
if (index < -length) {
|
32
32
|
return false;
|
33
33
|
}
|
34
34
|
index = length + index;
|
@@ -15,6 +15,12 @@ namespace duckdb {
|
|
15
15
|
// FIXME: use a local state for each thread to increase performance?
|
16
16
|
// FIXME: benchmark the use of simple_update against using update (if applicable)
|
17
17
|
|
18
|
+
static unique_ptr<FunctionData> ListAggregatesBindFailure(ScalarFunction &bound_function) {
|
19
|
+
bound_function.arguments[0] = LogicalType::SQLNULL;
|
20
|
+
bound_function.return_type = LogicalType::SQLNULL;
|
21
|
+
return make_uniq<VariableReturnBindData>(LogicalType::SQLNULL);
|
22
|
+
}
|
23
|
+
|
18
24
|
struct ListAggregatesBindData : public FunctionData {
|
19
25
|
ListAggregatesBindData(const LogicalType &stype_p, unique_ptr<Expression> aggr_expr_p);
|
20
26
|
~ListAggregatesBindData() override;
|
@@ -31,11 +37,24 @@ struct ListAggregatesBindData : public FunctionData {
|
|
31
37
|
return stype == other.stype && aggr_expr->Equals(*other.aggr_expr);
|
32
38
|
}
|
33
39
|
static void Serialize(FieldWriter &writer, const FunctionData *bind_data_p, const ScalarFunction &function) {
|
34
|
-
|
40
|
+
auto bind_data = dynamic_cast<const ListAggregatesBindData *>(bind_data_p);
|
41
|
+
if (!bind_data) {
|
42
|
+
writer.WriteField<bool>(false);
|
43
|
+
} else {
|
44
|
+
writer.WriteField<bool>(true);
|
45
|
+
writer.WriteSerializable(bind_data->stype);
|
46
|
+
writer.WriteSerializable(*bind_data->aggr_expr);
|
47
|
+
}
|
35
48
|
}
|
36
|
-
static unique_ptr<FunctionData> Deserialize(
|
49
|
+
static unique_ptr<FunctionData> Deserialize(PlanDeserializationState &state, FieldReader &reader,
|
37
50
|
ScalarFunction &bound_function) {
|
38
|
-
|
51
|
+
if (reader.ReadRequired<bool>()) {
|
52
|
+
auto s_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
|
53
|
+
auto expr = reader.ReadRequiredSerializable<Expression>(state);
|
54
|
+
return make_uniq<ListAggregatesBindData>(s_type, std::move(expr));
|
55
|
+
} else {
|
56
|
+
return ListAggregatesBindFailure(bound_function);
|
57
|
+
}
|
39
58
|
}
|
40
59
|
};
|
41
60
|
|
@@ -396,9 +415,7 @@ template <bool IS_AGGR = false>
|
|
396
415
|
static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, ScalarFunction &bound_function,
|
397
416
|
vector<unique_ptr<Expression>> &arguments) {
|
398
417
|
if (arguments[0]->return_type.id() == LogicalTypeId::SQLNULL) {
|
399
|
-
bound_function
|
400
|
-
bound_function.return_type = LogicalType::SQLNULL;
|
401
|
-
return make_uniq<VariableReturnBindData>(bound_function.return_type);
|
418
|
+
return ListAggregatesBindFailure(bound_function);
|
402
419
|
}
|
403
420
|
|
404
421
|
bool is_parameter = arguments[0]->return_type.id() == LogicalTypeId::UNKNOWN;
|
@@ -24,7 +24,7 @@ public:
|
|
24
24
|
static void Serialize(FieldWriter &writer, const FunctionData *bind_data_p, const ScalarFunction &function) {
|
25
25
|
throw NotImplementedException("FIXME: list lambda serialize");
|
26
26
|
}
|
27
|
-
static unique_ptr<FunctionData> Deserialize(
|
27
|
+
static unique_ptr<FunctionData> Deserialize(PlanDeserializationState &state, FieldReader &reader,
|
28
28
|
ScalarFunction &bound_function) {
|
29
29
|
throw NotImplementedException("FIXME: list lambda deserialize");
|
30
30
|
}
|
@@ -328,7 +328,6 @@ static unique_ptr<FunctionData> ListLambdaBind(ClientContext &context, ScalarFun
|
|
328
328
|
}
|
329
329
|
|
330
330
|
if (arguments[0]->return_type.id() == LogicalTypeId::SQLNULL) {
|
331
|
-
bound_function.arguments.pop_back();
|
332
331
|
bound_function.arguments[0] = LogicalType::SQLNULL;
|
333
332
|
bound_function.return_type = LogicalType::SQLNULL;
|
334
333
|
return make_uniq<VariableReturnBindData>(bound_function.return_type);
|
@@ -153,6 +153,9 @@ static unique_ptr<FunctionData> MapConcatBind(ClientContext &context, ScalarFunc
|
|
153
153
|
// The maps are allowed to be NULL
|
154
154
|
continue;
|
155
155
|
}
|
156
|
+
if (map.id() != LogicalTypeId::MAP) {
|
157
|
+
throw InvalidInputException("MAP_CONCAT only takes map arguments");
|
158
|
+
}
|
156
159
|
is_null = false;
|
157
160
|
if (IsEmptyMap(map)) {
|
158
161
|
// Map is allowed to be empty
|
@@ -502,13 +502,13 @@ struct RoundOperatorPrecision {
|
|
502
502
|
static inline TR Operation(TA input, TB precision) {
|
503
503
|
double rounded_value;
|
504
504
|
if (precision < 0) {
|
505
|
-
double modifier = std::pow(10, -precision);
|
505
|
+
double modifier = std::pow(10, -TA(precision));
|
506
506
|
rounded_value = (std::round(input / modifier)) * modifier;
|
507
507
|
if (std::isinf(rounded_value) || std::isnan(rounded_value)) {
|
508
508
|
return 0;
|
509
509
|
}
|
510
510
|
} else {
|
511
|
-
double modifier = std::pow(10, precision);
|
511
|
+
double modifier = std::pow(10, TA(precision));
|
512
512
|
rounded_value = (std::round(input * modifier)) / modifier;
|
513
513
|
if (std::isinf(rounded_value) || std::isnan(rounded_value)) {
|
514
514
|
return input;
|
@@ -574,7 +574,7 @@ static void DecimalRoundNegativePrecisionFunction(DataChunk &input, ExpressionSt
|
|
574
574
|
auto &info = func_expr.bind_info->Cast<RoundPrecisionFunctionData>();
|
575
575
|
auto source_scale = DecimalType::GetScale(func_expr.children[0]->return_type);
|
576
576
|
auto width = DecimalType::GetWidth(func_expr.children[0]->return_type);
|
577
|
-
if (
|
577
|
+
if (info.target_scale <= -int32_t(width)) {
|
578
578
|
// scale too big for width
|
579
579
|
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
580
580
|
result.SetValue(0, Value::INTEGER(0));
|
@@ -18,7 +18,6 @@
|
|
18
18
|
#include "duckdb/storage/table/scan_state.hpp"
|
19
19
|
|
20
20
|
#include <algorithm>
|
21
|
-
#include <cstring>
|
22
21
|
|
23
22
|
namespace duckdb {
|
24
23
|
|
@@ -347,7 +346,31 @@ bool ART::ConstructFromSorted(idx_t count, vector<ARTKey> &keys, Vector &row_ide
|
|
347
346
|
|
348
347
|
auto key_section = KeySection(0, count - 1, 0, 0);
|
349
348
|
auto has_constraint = IsUnique();
|
350
|
-
|
349
|
+
if (!Construct(*this, keys, row_ids, *this->tree, key_section, has_constraint)) {
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
|
353
|
+
#ifdef DEBUG
|
354
|
+
D_ASSERT(!VerifyAndToStringInternal(true).empty());
|
355
|
+
for (idx_t i = 0; i < count; i++) {
|
356
|
+
D_ASSERT(!keys[i].Empty());
|
357
|
+
auto leaf_node = Lookup(*tree, keys[i], 0);
|
358
|
+
D_ASSERT(leaf_node.IsSet());
|
359
|
+
auto &leaf = Leaf::Get(*this, leaf_node);
|
360
|
+
|
361
|
+
if (leaf.IsInlined()) {
|
362
|
+
D_ASSERT(row_ids[i] == leaf.row_ids.inlined);
|
363
|
+
continue;
|
364
|
+
}
|
365
|
+
|
366
|
+
D_ASSERT(leaf.row_ids.ptr.IsSet());
|
367
|
+
Node leaf_segment = leaf.row_ids.ptr;
|
368
|
+
auto position = leaf.FindRowId(*this, leaf_segment, row_ids[i]);
|
369
|
+
D_ASSERT(position != (uint32_t)DConstants::INVALID_INDEX);
|
370
|
+
}
|
371
|
+
#endif
|
372
|
+
|
373
|
+
return true;
|
351
374
|
}
|
352
375
|
|
353
376
|
//===--------------------------------------------------------------------===//
|
@@ -397,6 +420,29 @@ PreservedError ART::Insert(IndexLock &lock, DataChunk &input, Vector &row_ids) {
|
|
397
420
|
return PreservedError(ConstraintException("PRIMARY KEY or UNIQUE constraint violated: duplicate key \"%s\"",
|
398
421
|
AppendRowError(input, failed_index)));
|
399
422
|
}
|
423
|
+
|
424
|
+
#ifdef DEBUG
|
425
|
+
for (idx_t i = 0; i < input.size(); i++) {
|
426
|
+
if (keys[i].Empty()) {
|
427
|
+
continue;
|
428
|
+
}
|
429
|
+
|
430
|
+
auto leaf_node = Lookup(*tree, keys[i], 0);
|
431
|
+
D_ASSERT(leaf_node.IsSet());
|
432
|
+
auto &leaf = Leaf::Get(*this, leaf_node);
|
433
|
+
|
434
|
+
if (leaf.IsInlined()) {
|
435
|
+
D_ASSERT(row_identifiers[i] == leaf.row_ids.inlined);
|
436
|
+
continue;
|
437
|
+
}
|
438
|
+
|
439
|
+
D_ASSERT(leaf.row_ids.ptr.IsSet());
|
440
|
+
Node leaf_segment = leaf.row_ids.ptr;
|
441
|
+
auto position = leaf.FindRowId(*this, leaf_segment, row_identifiers[i]);
|
442
|
+
D_ASSERT(position != (uint32_t)DConstants::INVALID_INDEX);
|
443
|
+
}
|
444
|
+
#endif
|
445
|
+
|
400
446
|
return PreservedError();
|
401
447
|
}
|
402
448
|
|
@@ -535,16 +581,31 @@ void ART::Delete(IndexLock &state, DataChunk &input, Vector &row_ids) {
|
|
535
581
|
continue;
|
536
582
|
}
|
537
583
|
Erase(*tree, keys[i], 0, row_identifiers[i]);
|
584
|
+
}
|
585
|
+
|
538
586
|
#ifdef DEBUG
|
587
|
+
// verify that we removed all row IDs
|
588
|
+
for (idx_t i = 0; i < input.size(); i++) {
|
589
|
+
if (keys[i].Empty()) {
|
590
|
+
continue;
|
591
|
+
}
|
592
|
+
|
539
593
|
auto node = Lookup(*tree, keys[i], 0);
|
540
594
|
if (node.IsSet()) {
|
541
595
|
auto &leaf = Leaf::Get(*this, node);
|
542
|
-
|
543
|
-
|
596
|
+
|
597
|
+
if (leaf.IsInlined()) {
|
598
|
+
D_ASSERT(row_identifiers[i] != leaf.row_ids.inlined);
|
599
|
+
continue;
|
544
600
|
}
|
601
|
+
|
602
|
+
D_ASSERT(leaf.row_ids.ptr.IsSet());
|
603
|
+
Node leaf_segment = leaf.row_ids.ptr;
|
604
|
+
auto position = leaf.FindRowId(*this, leaf_segment, row_identifiers[i]);
|
605
|
+
D_ASSERT(position == (uint32_t)DConstants::INVALID_INDEX);
|
545
606
|
}
|
546
|
-
#endif
|
547
607
|
}
|
608
|
+
#endif
|
548
609
|
}
|
549
610
|
|
550
611
|
void ART::Erase(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id) {
|
@@ -1022,6 +1083,10 @@ void ART::Vacuum(IndexLock &state) {
|
|
1022
1083
|
|
1023
1084
|
// finalize the vacuum operation
|
1024
1085
|
FinalizeVacuum(flags);
|
1086
|
+
|
1087
|
+
for (auto &allocator : allocators) {
|
1088
|
+
allocator->Verify();
|
1089
|
+
}
|
1025
1090
|
}
|
1026
1091
|
|
1027
1092
|
//===--------------------------------------------------------------------===//
|
@@ -1059,6 +1124,10 @@ bool ART::MergeIndexes(IndexLock &state, Index &other_index) {
|
|
1059
1124
|
if (!tree->Merge(*this, *other_art.tree)) {
|
1060
1125
|
return false;
|
1061
1126
|
}
|
1127
|
+
|
1128
|
+
for (auto &allocator : allocators) {
|
1129
|
+
allocator->Verify();
|
1130
|
+
}
|
1062
1131
|
return true;
|
1063
1132
|
}
|
1064
1133
|
|
@@ -1066,9 +1135,13 @@ bool ART::MergeIndexes(IndexLock &state, Index &other_index) {
|
|
1066
1135
|
// Utility
|
1067
1136
|
//===--------------------------------------------------------------------===//
|
1068
1137
|
|
1069
|
-
string ART::
|
1138
|
+
string ART::VerifyAndToString(IndexLock &state, const bool only_verify) {
|
1139
|
+
return VerifyAndToStringInternal(only_verify);
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
string ART::VerifyAndToStringInternal(const bool only_verify) {
|
1070
1143
|
if (tree->IsSet()) {
|
1071
|
-
return tree->
|
1144
|
+
return "ART: " + tree->VerifyAndToString(*this, only_verify);
|
1072
1145
|
}
|
1073
1146
|
return "[empty]";
|
1074
1147
|
}
|
@@ -126,13 +126,20 @@ void FixedSizeAllocator::Merge(FixedSizeAllocator &other) {
|
|
126
126
|
|
127
127
|
bool FixedSizeAllocator::InitializeVacuum() {
|
128
128
|
|
129
|
+
if (total_allocations == 0) {
|
130
|
+
Reset();
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
|
129
134
|
auto total_available_allocations = allocations_per_buffer * buffers.size();
|
135
|
+
D_ASSERT(total_available_allocations >= total_allocations);
|
130
136
|
auto total_free_positions = total_available_allocations - total_allocations;
|
131
137
|
|
132
138
|
// vacuum_count buffers can be freed
|
133
|
-
auto vacuum_count = total_free_positions / allocations_per_buffer
|
139
|
+
auto vacuum_count = total_free_positions / allocations_per_buffer;
|
134
140
|
|
135
141
|
// calculate the vacuum threshold adaptively
|
142
|
+
D_ASSERT(vacuum_count < buffers.size());
|
136
143
|
idx_t memory_usage = GetMemoryUsage();
|
137
144
|
idx_t excess_memory_usage = vacuum_count * BUFFER_ALLOC_SIZE;
|
138
145
|
auto excess_percentage = (double)excess_memory_usage / (double)memory_usage;
|
@@ -171,10 +178,22 @@ SwizzleablePointer FixedSizeAllocator::VacuumPointer(const SwizzleablePointer pt
|
|
171
178
|
// buffer after the vacuum operation
|
172
179
|
|
173
180
|
auto new_ptr = New();
|
181
|
+
|
182
|
+
// new increases the allocation count
|
183
|
+
total_allocations--;
|
184
|
+
|
174
185
|
memcpy(Get(new_ptr), Get(ptr), allocation_size);
|
175
186
|
return new_ptr;
|
176
187
|
}
|
177
188
|
|
189
|
+
void FixedSizeAllocator::Verify() const {
|
190
|
+
#ifdef DEBUG
|
191
|
+
auto total_available_allocations = allocations_per_buffer * buffers.size();
|
192
|
+
D_ASSERT(total_available_allocations >= total_allocations);
|
193
|
+
D_ASSERT(buffers.size() >= buffers_with_free_space.size());
|
194
|
+
#endif
|
195
|
+
}
|
196
|
+
|
178
197
|
uint32_t FixedSizeAllocator::GetOffset(ValidityMask &mask, const idx_t allocation_count) {
|
179
198
|
|
180
199
|
auto data = mask.GetData();
|
@@ -60,16 +60,10 @@ void Leaf::Free(ART &art, Node &node) {
|
|
60
60
|
D_ASSERT(node.IsSet());
|
61
61
|
D_ASSERT(!node.IsSwizzled());
|
62
62
|
|
63
|
+
// free leaf segments
|
63
64
|
auto &leaf = Leaf::Get(art, node);
|
64
|
-
|
65
|
-
// delete all leaf segments
|
66
65
|
if (!leaf.IsInlined()) {
|
67
|
-
|
68
|
-
while (ptr.IsSet()) {
|
69
|
-
auto next_ptr = LeafSegment::Get(art, ptr).next;
|
70
|
-
Node::Free(art, ptr);
|
71
|
-
ptr = next_ptr;
|
72
|
-
}
|
66
|
+
Node::Free(art, leaf.row_ids.ptr);
|
73
67
|
}
|
74
68
|
}
|
75
69
|
|
@@ -275,10 +269,10 @@ uint32_t Leaf::FindRowId(const ART &art, Node &ptr, const row_t row_id) const {
|
|
275
269
|
return (uint32_t)DConstants::INVALID_INDEX;
|
276
270
|
}
|
277
271
|
|
278
|
-
string Leaf::
|
272
|
+
string Leaf::VerifyAndToString(const ART &art, const bool only_verify) const {
|
279
273
|
|
280
274
|
if (IsInlined()) {
|
281
|
-
return "
|
275
|
+
return only_verify ? "" : "Leaf [count: 1, row ID: " + to_string(row_ids.inlined) + "]";
|
282
276
|
}
|
283
277
|
|
284
278
|
auto ptr = row_ids.ptr;
|
@@ -296,7 +290,11 @@ string Leaf::ToString(const ART &art) const {
|
|
296
290
|
remaining -= to_string_count;
|
297
291
|
ptr = segment.next;
|
298
292
|
}
|
299
|
-
|
293
|
+
|
294
|
+
D_ASSERT(remaining == 0);
|
295
|
+
(void)this_count;
|
296
|
+
D_ASSERT(this_count == count);
|
297
|
+
return only_verify ? "" : "Leaf [count: " + to_string(count) + ", row IDs: " + str + "] \n";
|
300
298
|
}
|
301
299
|
|
302
300
|
BlockPointer Leaf::Serialize(const ART &art, MetaBlockWriter &writer) const {
|
@@ -366,6 +364,7 @@ void Leaf::Vacuum(ART &art) {
|
|
366
364
|
auto &allocator = Node::GetAllocator(art, NType::LEAF_SEGMENT);
|
367
365
|
if (allocator.NeedsVacuum(row_ids.ptr)) {
|
368
366
|
row_ids.ptr.SetPtr(allocator.VacuumPointer(row_ids.ptr));
|
367
|
+
row_ids.ptr.type = (uint8_t)NType::LEAF_SEGMENT;
|
369
368
|
}
|
370
369
|
|
371
370
|
auto ptr = row_ids.ptr;
|
@@ -374,6 +373,7 @@ void Leaf::Vacuum(ART &art) {
|
|
374
373
|
ptr = segment.next;
|
375
374
|
if (ptr.IsSet() && allocator.NeedsVacuum(ptr)) {
|
376
375
|
segment.next.SetPtr(allocator.VacuumPointer(ptr));
|
376
|
+
segment.next.type = (uint8_t)NType::LEAF_SEGMENT;
|
377
377
|
ptr = segment.next;
|
378
378
|
}
|
379
379
|
}
|
@@ -15,6 +15,16 @@ LeafSegment &LeafSegment::New(ART &art, Node &node) {
|
|
15
15
|
return segment;
|
16
16
|
}
|
17
17
|
|
18
|
+
void LeafSegment::Free(ART &art, Node &node) {
|
19
|
+
|
20
|
+
D_ASSERT(node.IsSet());
|
21
|
+
D_ASSERT(!node.IsSwizzled());
|
22
|
+
|
23
|
+
// free next segment
|
24
|
+
auto next_segment = LeafSegment::Get(art, node).next;
|
25
|
+
Node::Free(art, next_segment);
|
26
|
+
}
|
27
|
+
|
18
28
|
LeafSegment &LeafSegment::Append(ART &art, uint32_t &count, const row_t row_id) {
|
19
29
|
|
20
30
|
reference<LeafSegment> segment(*this);
|