duckdb 0.8.2-dev11.0 → 0.8.2-dev1182.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 +14 -12
- package/binding.gyp.in +1 -1
- package/configure.py +1 -1
- package/duckdb_extension_config.cmake +10 -0
- package/lib/duckdb.d.ts +59 -0
- package/lib/duckdb.js +21 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datefunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-list-range.cpp +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +7 -0
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +5 -5
- package/src/duckdb/extension/icu/icu-timebucket.cpp +16 -16
- package/src/duckdb/extension/icu/icu-timezone.cpp +8 -8
- package/src/duckdb/extension/icu/icu_extension.cpp +5 -7
- package/src/duckdb/extension/json/include/json_common.hpp +47 -231
- package/src/duckdb/extension/json/include/json_executors.hpp +49 -13
- package/src/duckdb/extension/json/include/json_functions.hpp +2 -1
- package/src/duckdb/extension/json/json_common.cpp +272 -40
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +17 -37
- package/src/duckdb/extension/json/json_functions/json_type.cpp +1 -1
- package/src/duckdb/extension/json/json_functions.cpp +24 -24
- package/src/duckdb/extension/json/json_scan.cpp +3 -6
- package/src/duckdb/extension/parquet/column_reader.cpp +19 -21
- package/src/duckdb/extension/parquet/column_writer.cpp +77 -61
- package/src/duckdb/extension/parquet/include/cast_column_reader.hpp +2 -2
- package/src/duckdb/extension/parquet/include/column_reader.hpp +14 -16
- package/src/duckdb/extension/parquet/include/column_writer.hpp +9 -7
- package/src/duckdb/extension/parquet/include/list_column_reader.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_dbp_decoder.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_decimal_utils.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_file_metadata_cache.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_statistics.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_support.hpp +9 -11
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +24 -5
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +1 -1
- package/src/duckdb/extension/parquet/include/struct_column_reader.hpp +2 -3
- package/src/duckdb/extension/parquet/include/zstd_file_system.hpp +2 -2
- package/src/duckdb/extension/parquet/parquet_extension.cpp +191 -19
- package/src/duckdb/extension/parquet/parquet_reader.cpp +5 -5
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +7 -6
- package/src/duckdb/extension/parquet/parquet_writer.cpp +79 -16
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +16 -0
- package/src/duckdb/src/common/adbc/adbc.cpp +75 -10
- package/src/duckdb/src/common/adbc/driver_manager.cpp +6 -11
- package/src/duckdb/src/common/allocator.cpp +14 -2
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +5 -10
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +0 -12
- package/src/duckdb/src/common/assert.cpp +3 -0
- package/src/duckdb/src/common/enum_util.cpp +42 -5
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +4 -0
- package/src/duckdb/src/common/enums/optimizer_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +4 -0
- package/src/duckdb/src/common/file_system.cpp +15 -0
- package/src/duckdb/src/common/local_file_system.cpp +1 -1
- package/src/duckdb/src/common/multi_file_reader.cpp +181 -18
- package/src/duckdb/src/common/radix_partitioning.cpp +27 -9
- package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
- package/src/duckdb/src/common/sort/merge_sorter.cpp +9 -16
- package/src/duckdb/src/common/sort/partition_state.cpp +44 -11
- package/src/duckdb/src/common/types/batched_data_collection.cpp +7 -2
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +9 -6
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +17 -2
- package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +15 -6
- package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
- package/src/duckdb/src/common/types/date.cpp +9 -0
- package/src/duckdb/src/common/types/list_segment.cpp +24 -74
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +3 -9
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +2 -0
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +2 -2
- package/src/duckdb/src/common/types/validity_mask.cpp +33 -0
- package/src/duckdb/src/common/types/vector.cpp +15 -14
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +6 -4
- package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +2 -2
- package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +5 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +8 -8
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +4 -3
- package/src/duckdb/src/core_functions/function_list.cpp +4 -2
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +208 -42
- package/src/duckdb/src/core_functions/scalar/date/epoch.cpp +0 -17
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +19 -4
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +4 -2
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +34 -18
- package/src/duckdb/src/execution/index/art/art.cpp +149 -139
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +1 -1
- package/src/duckdb/src/execution/index/art/iterator.cpp +129 -207
- package/src/duckdb/src/execution/index/art/leaf.cpp +8 -37
- package/src/duckdb/src/execution/index/art/node.cpp +113 -120
- package/src/duckdb/src/execution/index/art/node16.cpp +1 -10
- package/src/duckdb/src/execution/index/art/node256.cpp +1 -9
- package/src/duckdb/src/execution/index/art/node4.cpp +12 -13
- package/src/duckdb/src/execution/index/art/node48.cpp +1 -11
- package/src/duckdb/src/execution/index/art/prefix.cpp +228 -350
- package/src/duckdb/src/execution/join_hashtable.cpp +4 -4
- package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +1 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +8 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -22
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +512 -300
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -3
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +413 -282
- package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +21 -10
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +22 -3
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +100 -13
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +20 -0
- package/src/duckdb/src/execution/operator/persistent/csv_rejects_table.cpp +48 -0
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +2 -3
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +6 -4
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
- package/src/duckdb/src/execution/operator/persistent/physical_fixed_batch_copy.cpp +3 -3
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +2 -1
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +19 -0
- package/src/duckdb/src/execution/operator/set/physical_cte.cpp +160 -0
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +15 -5
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +41 -6
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +30 -5
- package/src/duckdb/src/execution/physical_operator.cpp +17 -14
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +43 -10
- package/src/duckdb/src/execution/physical_plan/plan_cte.cpp +33 -0
- package/src/duckdb/src/execution/physical_plan/plan_recursive_cte.cpp +25 -4
- package/src/duckdb/src/execution/physical_plan_generator.cpp +4 -0
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +290 -43
- package/src/duckdb/src/execution/window_segment_tree.cpp +286 -129
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +2 -1
- package/src/duckdb/src/function/function.cpp +2 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_integral.cpp +212 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +249 -0
- package/src/duckdb/src/function/scalar/compressed_materialization_functions.cpp +29 -0
- package/src/duckdb/src/function/scalar/list/list_resize.cpp +162 -0
- package/src/duckdb/src/function/scalar/nested_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/string/like.cpp +12 -4
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +12 -5
- package/src/duckdb/src/function/table/copy_csv.cpp +8 -1
- package/src/duckdb/src/function/table/read_csv.cpp +100 -17
- package/src/duckdb/src/function/table/system/test_all_types.cpp +38 -18
- package/src/duckdb/src/function/table/table_scan.cpp +9 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/bswap.hpp +42 -0
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/enums/cte_materialize.hpp +21 -0
- package/src/duckdb/src/include/duckdb/common/enums/joinref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/optimizer_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +10 -42
- package/src/duckdb/src/include/duckdb/common/mutex.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/radix.hpp +9 -20
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +6 -21
- package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_segment.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_scan_states.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/date.hpp +7 -5
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +6 -8
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +0 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +4 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +1 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +3 -3
- package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +24 -6
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +21 -3
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +4 -5
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +31 -27
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +6 -14
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +4 -10
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +5 -8
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +63 -52
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -10
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_line_info.hpp +4 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_rejects_table.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +10 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_cte.hpp +62 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +8 -2
- package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +10 -3
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +51 -40
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/compressed_materialization_functions.hpp +49 -0
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +5 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +21 -1
- package/src/duckdb/src/include/duckdb/optimizer/column_binding_replacer.hpp +47 -0
- package/src/duckdb/src/include/duckdb/optimizer/compressed_materialization.hpp +132 -0
- package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +13 -16
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/estimated_properties.hpp +10 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +13 -0
- package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/remove_duplicate_groups.hpp +40 -0
- package/src/duckdb/src/include/duckdb/optimizer/statistics_propagator.hpp +11 -3
- package/src/duckdb/src/include/duckdb/optimizer/topn_optimizer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/cte_node.hpp +54 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +15 -8
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +8 -5
- package/src/duckdb/src/include/duckdb/planner/bound_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/lateral_binder.hpp +0 -2
- package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +5 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +7 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dependent_join.hpp +43 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +49 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +5 -4
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_cte_node.hpp +44 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/subquery/has_correlated_expressions.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/subquery/recursive_dependent_join_planner.hpp +31 -0
- package/src/duckdb/src/include/duckdb/planner/subquery/rewrite_correlated_expressions.hpp +8 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_cteref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/object_cache.hpp +22 -0
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -3
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +2 -3
- package/src/duckdb/src/include/duckdb.h +28 -0
- package/src/duckdb/src/main/capi/arrow-c.cpp +155 -1
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/extension/extension_helper.cpp +96 -89
- package/src/duckdb/src/main/settings/settings.cpp +40 -18
- package/src/duckdb/src/optimizer/column_binding_replacer.cpp +43 -0
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
- package/src/duckdb/src/optimizer/compressed_materialization/compress_aggregate.cpp +140 -0
- package/src/duckdb/src/optimizer/compressed_materialization/compress_distinct.cpp +42 -0
- package/src/duckdb/src/optimizer/compressed_materialization/compress_order.cpp +65 -0
- package/src/duckdb/src/optimizer/compressed_materialization.cpp +478 -0
- package/src/duckdb/src/optimizer/deliminator.cpp +176 -321
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +9 -0
- package/src/duckdb/src/optimizer/join_order/estimated_properties.cpp +7 -0
- package/src/duckdb/src/optimizer/join_order/join_node.cpp +2 -2
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +113 -82
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +2 -6
- package/src/duckdb/src/optimizer/join_order/query_graph.cpp +22 -14
- package/src/duckdb/src/optimizer/optimizer.cpp +51 -14
- package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +5 -5
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +0 -1
- package/src/duckdb/src/optimizer/remove_duplicate_groups.cpp +127 -0
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +4 -0
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +154 -15
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +65 -8
- package/src/duckdb/src/optimizer/statistics/operator/propagate_order.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +7 -5
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +20 -10
- package/src/duckdb/src/parallel/executor.cpp +15 -0
- package/src/duckdb/src/parallel/pipeline_executor.cpp +7 -6
- package/src/duckdb/src/parallel/task_scheduler.cpp +11 -2
- package/src/duckdb/src/parser/common_table_expression_info.cpp +2 -0
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +1 -1
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +7 -0
- package/src/duckdb/src/parser/query_node/cte_node.cpp +75 -0
- package/src/duckdb/src/parser/query_node.cpp +18 -1
- package/src/duckdb/src/parser/tableref/joinref.cpp +3 -0
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +55 -3
- package/src/duckdb/src/parser/transform/expression/transform_expression.cpp +2 -0
- package/src/duckdb/src/parser/transform/expression/transform_multi_assign_reference.cpp +44 -0
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +19 -1
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +13 -0
- package/src/duckdb/src/parser/transform/statement/transform_delete.cpp +6 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +6 -1
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +7 -2
- package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +14 -11
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +11 -2
- package/src/duckdb/src/parser/transform/statement/transform_update.cpp +6 -1
- package/src/duckdb/src/parser/transformer.cpp +15 -0
- package/src/duckdb/src/planner/binder/query_node/bind_cte_node.cpp +64 -0
- package/src/duckdb/src/planner/binder/query_node/plan_cte_node.cpp +26 -0
- package/src/duckdb/src/planner/binder/query_node/plan_recursive_cte_node.cpp +5 -5
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +4 -4
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +32 -29
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +11 -2
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +32 -5
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +116 -50
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +61 -26
- package/src/duckdb/src/planner/binder/tableref/plan_subqueryref.cpp +3 -3
- package/src/duckdb/src/planner/binder.cpp +5 -0
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +4 -31
- package/src/duckdb/src/planner/expression_binder.cpp +3 -0
- package/src/duckdb/src/planner/expression_iterator.cpp +6 -0
- package/src/duckdb/src/planner/logical_operator.cpp +5 -0
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +2 -0
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +3 -1
- package/src/duckdb/src/planner/operator/logical_dependent_join.cpp +26 -0
- package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +21 -0
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +90 -38
- package/src/duckdb/src/planner/subquery/has_correlated_expressions.cpp +22 -7
- package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +65 -7
- package/src/duckdb/src/storage/arena_allocator.cpp +1 -2
- package/src/duckdb/src/storage/buffer/block_manager.cpp +3 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -0
- package/src/duckdb/src/storage/data_table.cpp +1 -1
- package/src/duckdb/src/storage/local_storage.cpp +3 -3
- package/src/duckdb/src/storage/single_file_block_manager.cpp +23 -0
- package/src/duckdb/src/storage/statistics/string_stats.cpp +21 -2
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/storage_manager.cpp +7 -2
- package/src/duckdb/src/storage/table/chunk_info.cpp +17 -0
- package/src/duckdb/src/storage/table/row_group.cpp +25 -9
- package/src/duckdb/src/storage/table/row_group_collection.cpp +19 -18
- package/src/duckdb/third_party/concurrentqueue/concurrentqueue.h +2 -2
- package/src/duckdb/third_party/concurrentqueue/lightweightsemaphore.h +76 -0
- package/src/duckdb/third_party/fast_float/fast_float/fast_float.h +2 -0
- package/src/duckdb/third_party/httplib/httplib.hpp +10 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +9 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12487 -12331
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
- package/src/duckdb/ub_src_execution_index_art.cpp +0 -2
- package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_set.cpp +2 -0
- package/src/duckdb/ub_src_execution_physical_plan.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_compressed_materialization.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_list.cpp +2 -0
- package/src/duckdb/ub_src_optimizer.cpp +6 -0
- package/src/duckdb/ub_src_optimizer_compressed_materialization.cpp +6 -0
- package/src/duckdb/ub_src_optimizer_statistics_expression.cpp +0 -2
- package/src/duckdb/ub_src_parser_query_node.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_query_node.cpp +4 -0
- package/src/duckdb/ub_src_planner_operator.cpp +4 -0
- package/src/duckdb_node.hpp +1 -0
- package/src/statement.cpp +103 -4
- package/test/columns.test.ts +243 -0
- package/test/test_all_types.test.ts +233 -0
- package/tsconfig.json +1 -0
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +0 -42
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +0 -40
- package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +0 -118
@@ -58,9 +58,6 @@ GroupedAggregateHashTable::GroupedAggregateHashTable(ClientContext &context, All
|
|
58
58
|
data_collection = make_uniq<TupleDataCollection>(buffer_manager, layout);
|
59
59
|
data_collection->InitializeAppend(td_pin_state, TupleDataPinProperties::KEEP_EVERYTHING_PINNED);
|
60
60
|
|
61
|
-
hashes_hdl = buffer_manager.Allocate(Storage::BLOCK_SIZE);
|
62
|
-
hashes_hdl_ptr = hashes_hdl.Ptr();
|
63
|
-
|
64
61
|
switch (entry_type) {
|
65
62
|
case HtEntryType::HT_WIDTH_64: {
|
66
63
|
hash_prefix_shift = (HASH_WIDTH - sizeof(aggr_ht_entry_64::salt)) * 8;
|
@@ -100,7 +97,7 @@ void GroupedAggregateHashTable::Destroy() {
|
|
100
97
|
}
|
101
98
|
|
102
99
|
// There are aggregates with destructors: Call the destructor for each of the aggregates
|
103
|
-
RowOperationsState state(aggregate_allocator
|
100
|
+
RowOperationsState state(*aggregate_allocator);
|
104
101
|
TupleDataChunkIterator iterator(*data_collection, TupleDataPinProperties::DESTROY_AFTER_DONE, false);
|
105
102
|
auto &row_locations = iterator.GetChunkState().row_locations;
|
106
103
|
do {
|
@@ -182,10 +179,8 @@ void GroupedAggregateHashTable::Resize(idx_t size) {
|
|
182
179
|
|
183
180
|
bitmask = capacity - 1;
|
184
181
|
const auto byte_size = capacity * sizeof(ENTRY);
|
185
|
-
|
186
|
-
|
187
|
-
hashes_hdl_ptr = hashes_hdl.Ptr();
|
188
|
-
}
|
182
|
+
hashes_hdl = buffer_manager.GetBufferAllocator().Allocate(byte_size);
|
183
|
+
hashes_hdl_ptr = hashes_hdl.get();
|
189
184
|
memset(hashes_hdl_ptr, 0, byte_size);
|
190
185
|
|
191
186
|
if (Count() != 0) {
|
@@ -277,7 +272,7 @@ idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChu
|
|
277
272
|
auto &aggregates = layout.GetAggregates();
|
278
273
|
idx_t filter_idx = 0;
|
279
274
|
idx_t payload_idx = 0;
|
280
|
-
RowOperationsState row_state(aggregate_allocator
|
275
|
+
RowOperationsState row_state(*aggregate_allocator);
|
281
276
|
for (idx_t i = 0; i < aggregates.size(); i++) {
|
282
277
|
auto &aggr = aggregates[i];
|
283
278
|
if (filter_idx >= filter.size() || i < filter[filter_idx]) {
|
@@ -322,7 +317,7 @@ void GroupedAggregateHashTable::FetchAggregates(DataChunk &groups, DataChunk &re
|
|
322
317
|
Vector addresses(LogicalType::POINTER);
|
323
318
|
FindOrCreateGroups(append_state, groups, addresses);
|
324
319
|
// now fetch the aggregates
|
325
|
-
RowOperationsState row_state(aggregate_allocator
|
320
|
+
RowOperationsState row_state(*aggregate_allocator);
|
326
321
|
RowOperations::FinalizeStates(row_state, layout, addresses, result, 0);
|
327
322
|
}
|
328
323
|
|
@@ -581,7 +576,7 @@ void GroupedAggregateHashTable::Combine(GroupedAggregateHashTable &other) {
|
|
581
576
|
}
|
582
577
|
|
583
578
|
FlushMoveState state(*other.data_collection);
|
584
|
-
RowOperationsState row_state(aggregate_allocator
|
579
|
+
RowOperationsState row_state(*aggregate_allocator);
|
585
580
|
while (state.Scan()) {
|
586
581
|
FindOrCreateGroups(state.append_state, state.groups, state.hashes, state.group_addresses, state.new_groups_sel);
|
587
582
|
RowOperations::CombineStates(row_state, layout, state.scan_state.chunk_state.row_locations,
|
@@ -591,14 +586,27 @@ void GroupedAggregateHashTable::Combine(GroupedAggregateHashTable &other) {
|
|
591
586
|
Verify();
|
592
587
|
}
|
593
588
|
|
594
|
-
void GroupedAggregateHashTable::
|
589
|
+
void GroupedAggregateHashTable::Append(GroupedAggregateHashTable &other) {
|
590
|
+
data_collection->Combine(other.GetDataCollection());
|
591
|
+
|
592
|
+
// Inherit ownership to all stored aggregate allocators
|
593
|
+
stored_allocators.emplace_back(other.aggregate_allocator);
|
594
|
+
for (const auto &stored_allocator : other.stored_allocators) {
|
595
|
+
stored_allocators.emplace_back(stored_allocator);
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
void GroupedAggregateHashTable::Partition(vector<GroupedAggregateHashTable *> &partition_hts, idx_t radix_bits,
|
600
|
+
bool sink_done) {
|
595
601
|
const auto num_partitions = RadixPartitioning::NumberOfPartitions(radix_bits);
|
596
602
|
D_ASSERT(partition_hts.size() == num_partitions);
|
597
603
|
|
598
604
|
// Partition the data
|
605
|
+
auto pin_properties =
|
606
|
+
sink_done ? TupleDataPinProperties::UNPIN_AFTER_DONE : TupleDataPinProperties::KEEP_EVERYTHING_PINNED;
|
599
607
|
auto partitioned_data =
|
600
608
|
make_uniq<RadixPartitionedTupleData>(buffer_manager, layout, radix_bits, layout.ColumnCount() - 1);
|
601
|
-
partitioned_data->Partition(*data_collection,
|
609
|
+
partitioned_data->Partition(*data_collection, pin_properties);
|
602
610
|
D_ASSERT(partitioned_data->GetPartitions().size() == num_partitions);
|
603
611
|
|
604
612
|
// Move the partitioned data collections to the partitioned hash tables and initialize the 1st part of the HT
|
@@ -606,9 +614,17 @@ void GroupedAggregateHashTable::Partition(vector<GroupedAggregateHashTable *> &p
|
|
606
614
|
for (idx_t partition_idx = 0; partition_idx < num_partitions; partition_idx++) {
|
607
615
|
auto &partition_ht = *partition_hts[partition_idx];
|
608
616
|
partition_ht.data_collection = std::move(partitions[partition_idx]);
|
609
|
-
|
610
|
-
|
611
|
-
partition_ht.
|
617
|
+
|
618
|
+
// Inherit ownership to all stored aggregate allocators
|
619
|
+
partition_ht.stored_allocators.emplace_back(aggregate_allocator);
|
620
|
+
for (const auto &stored_allocator : stored_allocators) {
|
621
|
+
partition_ht.stored_allocators.emplace_back(stored_allocator);
|
622
|
+
}
|
623
|
+
|
624
|
+
if (!sink_done) {
|
625
|
+
partition_ht.InitializeFirstPart();
|
626
|
+
partition_ht.Verify();
|
627
|
+
}
|
612
628
|
}
|
613
629
|
}
|
614
630
|
|
@@ -631,7 +647,7 @@ idx_t GroupedAggregateHashTable::Scan(TupleDataParallelScanState &gstate, TupleD
|
|
631
647
|
DataChunk &result) {
|
632
648
|
data_collection->Scan(gstate, lstate, result);
|
633
649
|
|
634
|
-
RowOperationsState row_state(aggregate_allocator
|
650
|
+
RowOperationsState row_state(*aggregate_allocator);
|
635
651
|
const auto group_cols = layout.ColumnCount() - 1;
|
636
652
|
RowOperations::FinalizeStates(row_state, layout, lstate.chunk_state.row_locations, result, group_cols);
|
637
653
|
|
@@ -644,7 +660,7 @@ void GroupedAggregateHashTable::Finalize() {
|
|
644
660
|
}
|
645
661
|
|
646
662
|
// Early release hashes (not needed for partition/scan) and data collection (will be pinned again when scanning)
|
647
|
-
hashes_hdl.
|
663
|
+
hashes_hdl.Reset();
|
648
664
|
data_collection->FinalizePinState(td_pin_state);
|
649
665
|
data_collection->Unpin();
|
650
666
|
|
@@ -5,7 +5,6 @@
|
|
5
5
|
#include "duckdb/execution/expression_executor.hpp"
|
6
6
|
#include "duckdb/storage/arena_allocator.hpp"
|
7
7
|
#include "duckdb/execution/index/art/art_key.hpp"
|
8
|
-
#include "duckdb/execution/index/art/prefix_segment.hpp"
|
9
8
|
#include "duckdb/execution/index/art/leaf_segment.hpp"
|
10
9
|
#include "duckdb/execution/index/art/prefix.hpp"
|
11
10
|
#include "duckdb/execution/index/art/leaf.hpp"
|
@@ -44,7 +43,7 @@ ART::ART(const vector<column_t> &column_ids, TableIOManager &table_io_manager,
|
|
44
43
|
}
|
45
44
|
|
46
45
|
// initialize all allocators
|
47
|
-
allocators.emplace_back(make_uniq<FixedSizeAllocator>(sizeof(
|
46
|
+
allocators.emplace_back(make_uniq<FixedSizeAllocator>(sizeof(Prefix), buffer_manager.GetBufferAllocator()));
|
48
47
|
allocators.emplace_back(make_uniq<FixedSizeAllocator>(sizeof(LeafSegment), buffer_manager.GetBufferAllocator()));
|
49
48
|
allocators.emplace_back(make_uniq<FixedSizeAllocator>(sizeof(Leaf), buffer_manager.GetBufferAllocator()));
|
50
49
|
allocators.emplace_back(make_uniq<FixedSizeAllocator>(sizeof(Node4), buffer_manager.GetBufferAllocator()));
|
@@ -306,10 +305,12 @@ bool Construct(ART &art, vector<ARTKey> &keys, row_t *row_ids, Node &node, KeySe
|
|
306
305
|
return false;
|
307
306
|
}
|
308
307
|
|
308
|
+
reference<Node> ref_node(node);
|
309
|
+
Prefix::New(art, ref_node, start_key, prefix_start, start_key.len - prefix_start);
|
309
310
|
if (single_row_id) {
|
310
|
-
Leaf::New(art,
|
311
|
+
Leaf::New(art, ref_node, row_ids[key_section.start]);
|
311
312
|
} else {
|
312
|
-
Leaf::New(art,
|
313
|
+
Leaf::New(art, ref_node, row_ids + key_section.start, num_row_ids);
|
313
314
|
}
|
314
315
|
return true;
|
315
316
|
}
|
@@ -320,17 +321,20 @@ bool Construct(ART &art, vector<ARTKey> &keys, row_t *row_ids, Node &node, KeySe
|
|
320
321
|
vector<KeySection> child_sections;
|
321
322
|
GetChildSections(child_sections, keys, key_section);
|
322
323
|
|
323
|
-
|
324
|
-
Node
|
325
|
-
|
324
|
+
// set the prefix
|
325
|
+
reference<Node> ref_node(node);
|
326
326
|
auto prefix_length = key_section.depth - prefix_start;
|
327
|
-
|
327
|
+
Prefix::New(art, ref_node, start_key, prefix_start, prefix_length);
|
328
|
+
|
329
|
+
// set the node
|
330
|
+
auto node_type = Node::GetARTNodeTypeByCount(child_sections.size());
|
331
|
+
Node::New(art, ref_node, node_type);
|
328
332
|
|
329
333
|
// recurse on each child section
|
330
334
|
for (auto &child_section : child_sections) {
|
331
335
|
Node new_child;
|
332
336
|
auto no_violation = Construct(art, keys, row_ids, new_child, child_section, has_constraint);
|
333
|
-
Node::InsertChild(art,
|
337
|
+
Node::InsertChild(art, ref_node, child_section.key_byte, new_child);
|
334
338
|
if (!no_violation) {
|
335
339
|
return false;
|
336
340
|
}
|
@@ -485,73 +489,75 @@ bool ART::InsertToLeaf(Node &leaf_node, const row_t &row_id) {
|
|
485
489
|
|
486
490
|
bool ART::Insert(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id) {
|
487
491
|
|
492
|
+
// node is currently empty, create a leaf here with the key
|
488
493
|
if (!node.IsSet()) {
|
489
|
-
|
490
|
-
|
494
|
+
D_ASSERT(depth <= key.len);
|
495
|
+
reference<Node> ref_node(node);
|
496
|
+
Prefix::New(*this, ref_node, key, depth, key.len - depth);
|
497
|
+
Leaf::New(*this, ref_node, row_id);
|
491
498
|
return true;
|
492
499
|
}
|
493
500
|
|
494
|
-
|
501
|
+
auto node_type = node.DecodeARTNodeType();
|
495
502
|
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
return InsertToLeaf(node, row_id);
|
501
|
-
}
|
503
|
+
// insert the row ID into this leaf
|
504
|
+
if (node_type == NType::LEAF) {
|
505
|
+
return InsertToLeaf(node, row_id);
|
506
|
+
}
|
502
507
|
|
503
|
-
|
504
|
-
|
505
|
-
auto
|
506
|
-
new_n4.prefix.Initialize(*this, key, depth, mismatch_position);
|
508
|
+
if (node_type != NType::PREFIX) {
|
509
|
+
D_ASSERT(depth < key.len);
|
510
|
+
auto child = node.GetChild(*this, key[depth]);
|
507
511
|
|
508
|
-
|
509
|
-
|
512
|
+
// recurse, if a child exists at key[depth]
|
513
|
+
if (child) {
|
514
|
+
bool success = Insert(*child, key, depth + 1, row_id);
|
515
|
+
node.ReplaceChild(*this, key[depth], *child);
|
516
|
+
return success;
|
517
|
+
}
|
510
518
|
|
519
|
+
// insert a new leaf node at key[depth]
|
511
520
|
Node leaf_node;
|
512
|
-
|
513
|
-
|
514
|
-
|
521
|
+
if (depth + 1 < key.len) {
|
522
|
+
reference<Node> ref_node(leaf_node);
|
523
|
+
Prefix::New(*this, ref_node, key, depth + 1, key.len - depth - 1);
|
524
|
+
Leaf::New(*this, ref_node, row_id);
|
525
|
+
} else {
|
526
|
+
Leaf::New(*this, leaf_node, row_id);
|
527
|
+
}
|
528
|
+
Node::InsertChild(*this, node, key[depth], leaf_node);
|
515
529
|
return true;
|
516
530
|
}
|
517
531
|
|
518
|
-
//
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
auto mismatch_position = old_node_prefix.KeyMismatchPosition(*this, key, depth);
|
523
|
-
if (mismatch_position != old_node_prefix.count) {
|
524
|
-
|
525
|
-
// prefix differs, create new node
|
526
|
-
auto old_node = node;
|
527
|
-
auto &new_n4 = Node4::New(*this, node);
|
528
|
-
new_n4.prefix.Initialize(*this, key, depth, mismatch_position);
|
532
|
+
// this is a prefix node, traverse
|
533
|
+
reference<Node> next_node(node);
|
534
|
+
auto mismatch_position = Prefix::Traverse(*this, next_node, key, depth);
|
529
535
|
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
Node leaf_node;
|
534
|
-
Leaf::New(*this, leaf_node, key, depth + mismatch_position + 1, row_id);
|
535
|
-
Node4::InsertChild(*this, node, key[depth + mismatch_position], leaf_node);
|
536
|
-
|
537
|
-
return true;
|
538
|
-
}
|
539
|
-
depth += node.GetPrefix(*this).count;
|
536
|
+
// prefix matches key
|
537
|
+
if (next_node.get().DecodeARTNodeType() != NType::PREFIX) {
|
538
|
+
return Insert(next_node, key, depth, row_id);
|
540
539
|
}
|
541
540
|
|
542
|
-
//
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
541
|
+
// prefix does not match the key, we need to create a new Node4; this new Node4 has two children,
|
542
|
+
// the remaining part of the prefix, and the new leaf
|
543
|
+
Node remaining_prefix;
|
544
|
+
auto prefix_byte = Prefix::GetByte(*this, next_node, mismatch_position);
|
545
|
+
Prefix::Split(*this, next_node, remaining_prefix, mismatch_position);
|
546
|
+
Node4::New(*this, next_node);
|
547
|
+
|
548
|
+
// insert remaining prefix
|
549
|
+
Node4::InsertChild(*this, next_node, prefix_byte, remaining_prefix);
|
550
550
|
|
551
|
-
// insert
|
551
|
+
// insert new leaf
|
552
552
|
Node leaf_node;
|
553
|
-
|
554
|
-
|
553
|
+
if (depth + 1 < key.len) {
|
554
|
+
reference<Node> ref_node(leaf_node);
|
555
|
+
Prefix::New(*this, ref_node, key, depth + 1, key.len - depth - 1);
|
556
|
+
Leaf::New(*this, ref_node, row_id);
|
557
|
+
} else {
|
558
|
+
Leaf::New(*this, leaf_node, row_id);
|
559
|
+
}
|
560
|
+
Node4::InsertChild(*this, next_node, key[depth], leaf_node);
|
555
561
|
return true;
|
556
562
|
}
|
557
563
|
|
@@ -614,9 +620,18 @@ void ART::Erase(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id)
|
|
614
620
|
return;
|
615
621
|
}
|
616
622
|
|
617
|
-
//
|
618
|
-
|
619
|
-
|
623
|
+
// handle prefix
|
624
|
+
reference<Node> next_node(node);
|
625
|
+
if (next_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
626
|
+
Prefix::Traverse(*this, next_node, key, depth);
|
627
|
+
if (next_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
628
|
+
return;
|
629
|
+
}
|
630
|
+
}
|
631
|
+
|
632
|
+
// delete a row ID from a leaf (root is leaf with possible prefix nodes)
|
633
|
+
if (next_node.get().DecodeARTNodeType() == NType::LEAF) {
|
634
|
+
auto &leaf = Leaf::Get(*this, next_node.get());
|
620
635
|
leaf.Remove(*this, row_id);
|
621
636
|
|
622
637
|
if (leaf.count == 0) {
|
@@ -626,34 +641,35 @@ void ART::Erase(Node &node, const ARTKey &key, idx_t depth, const row_t &row_id)
|
|
626
641
|
return;
|
627
642
|
}
|
628
643
|
|
629
|
-
|
630
|
-
auto
|
631
|
-
if (node_prefix.count) {
|
632
|
-
if (node_prefix.KeyMismatchPosition(*this, key, depth) != node_prefix.count) {
|
633
|
-
return;
|
634
|
-
}
|
635
|
-
depth += node_prefix.count;
|
636
|
-
}
|
637
|
-
|
638
|
-
auto child = node.GetChild(*this, key[depth]);
|
644
|
+
D_ASSERT(depth < key.len);
|
645
|
+
auto child = next_node.get().GetChild(*this, key[depth]);
|
639
646
|
if (child) {
|
640
647
|
D_ASSERT(child->IsSet());
|
641
648
|
|
642
|
-
|
649
|
+
auto temp_depth = depth + 1;
|
650
|
+
reference<Node> child_node(*child);
|
651
|
+
if (child_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
652
|
+
Prefix::Traverse(*this, child_node, key, temp_depth);
|
653
|
+
if (child_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
654
|
+
return;
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
if (child_node.get().DecodeARTNodeType() == NType::LEAF) {
|
643
659
|
// leaf found, remove entry
|
644
|
-
auto &leaf = Leaf::Get(*this,
|
660
|
+
auto &leaf = Leaf::Get(*this, child_node.get());
|
645
661
|
leaf.Remove(*this, row_id);
|
646
662
|
|
647
663
|
if (leaf.count == 0) {
|
648
664
|
// leaf is empty, delete leaf, decrement node counter and maybe shrink node
|
649
|
-
Node::DeleteChild(*this, node, key[depth]);
|
665
|
+
Node::DeleteChild(*this, next_node, node, key[depth]);
|
650
666
|
}
|
651
667
|
return;
|
652
668
|
}
|
653
669
|
|
654
670
|
// recurse
|
655
671
|
Erase(*child, key, depth + 1, row_id);
|
656
|
-
|
672
|
+
next_node.get().ReplaceChild(*this, key[depth], *child);
|
657
673
|
}
|
658
674
|
}
|
659
675
|
|
@@ -733,35 +749,28 @@ void ART::SearchEqualJoinNoFetch(ARTKey &key, idx_t &result_size) {
|
|
733
749
|
Node ART::Lookup(Node node, const ARTKey &key, idx_t depth) {
|
734
750
|
|
735
751
|
while (node.IsSet()) {
|
736
|
-
if (node.DecodeARTNodeType() == NType::LEAF) {
|
737
|
-
auto &leaf = Leaf::Get(*this, node);
|
738
752
|
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
753
|
+
// traverse prefix, if exists
|
754
|
+
reference<Node> next_node(node);
|
755
|
+
if (next_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
756
|
+
Prefix::Traverse(*this, next_node, key, depth);
|
757
|
+
if (next_node.get().DecodeARTNodeType() == NType::PREFIX) {
|
758
|
+
return Node();
|
744
759
|
}
|
745
|
-
return node;
|
746
760
|
}
|
747
|
-
|
748
|
-
if (
|
749
|
-
|
750
|
-
if (key[depth + pos] != node_prefix.GetByte(*this, pos)) {
|
751
|
-
// prefix mismatch, subtree of node does not contain key
|
752
|
-
return Node();
|
753
|
-
}
|
754
|
-
}
|
755
|
-
depth += node_prefix.count;
|
761
|
+
|
762
|
+
if (next_node.get().DecodeARTNodeType() == NType::LEAF) {
|
763
|
+
return next_node.get();
|
756
764
|
}
|
757
765
|
|
758
|
-
|
759
|
-
auto child =
|
766
|
+
D_ASSERT(depth < key.len);
|
767
|
+
auto child = next_node.get().GetChild(*this, key[depth]);
|
760
768
|
if (!child) {
|
769
|
+
// prefix matches key, but no child at byte, ART/subtree does not contain key
|
761
770
|
return Node();
|
762
771
|
}
|
763
772
|
|
764
|
-
//
|
773
|
+
// lookup in child node
|
765
774
|
node = *child;
|
766
775
|
D_ASSERT(node.IsSet());
|
767
776
|
depth++;
|
@@ -771,21 +780,21 @@ Node ART::Lookup(Node node, const ARTKey &key, idx_t depth) {
|
|
771
780
|
}
|
772
781
|
|
773
782
|
//===--------------------------------------------------------------------===//
|
774
|
-
// Greater Than
|
775
|
-
// Returns: True (If found leaf >= key)
|
776
|
-
// False (Otherwise)
|
783
|
+
// Greater Than and Less Than
|
777
784
|
//===--------------------------------------------------------------------===//
|
778
785
|
|
779
|
-
bool ART::SearchGreater(ARTIndexScanState &state, ARTKey &key, bool
|
780
|
-
vector<row_t> &result_ids) {
|
786
|
+
bool ART::SearchGreater(ARTIndexScanState &state, ARTKey &key, bool equal, idx_t max_count, vector<row_t> &result_ids) {
|
781
787
|
|
782
|
-
|
788
|
+
if (!tree->IsSet()) {
|
789
|
+
return true;
|
790
|
+
}
|
791
|
+
Iterator &it = state.iterator;
|
783
792
|
|
784
|
-
//
|
785
|
-
// that satisfies our requirement
|
793
|
+
// find the lowest value that satisfies the predicate
|
786
794
|
if (!it.art) {
|
787
795
|
it.art = this;
|
788
|
-
if (!it.LowerBound(*tree, key,
|
796
|
+
if (!it.LowerBound(*tree, key, equal, 0)) {
|
797
|
+
// early-out, if the maximum value in the ART is lower than the lower bound
|
789
798
|
return true;
|
790
799
|
}
|
791
800
|
}
|
@@ -796,86 +805,84 @@ bool ART::SearchGreater(ARTIndexScanState &state, ARTKey &key, bool inclusive, i
|
|
796
805
|
return it.Scan(empty_key, max_count, result_ids, false);
|
797
806
|
}
|
798
807
|
|
799
|
-
|
800
|
-
// Less Than
|
801
|
-
//===--------------------------------------------------------------------===//
|
802
|
-
|
803
|
-
bool ART::SearchLess(ARTIndexScanState &state, ARTKey &upper_bound, bool inclusive, idx_t max_count,
|
808
|
+
bool ART::SearchLess(ARTIndexScanState &state, ARTKey &upper_bound, bool equal, idx_t max_count,
|
804
809
|
vector<row_t> &result_ids) {
|
805
810
|
|
806
811
|
if (!tree->IsSet()) {
|
807
812
|
return true;
|
808
813
|
}
|
809
|
-
|
810
|
-
auto &it = state.iterator;
|
814
|
+
Iterator &it = state.iterator;
|
811
815
|
|
812
816
|
if (!it.art) {
|
813
817
|
it.art = this;
|
814
|
-
//
|
818
|
+
// find the minimum value in the ART: we start scanning from this value
|
815
819
|
it.FindMinimum(*tree);
|
816
|
-
// early
|
817
|
-
if (it.
|
820
|
+
// early-out, if the minimum value is higher than the upper bound
|
821
|
+
if (it.current_key > upper_bound) {
|
818
822
|
return true;
|
819
823
|
}
|
820
824
|
}
|
821
825
|
|
822
826
|
// now continue the scan until we reach the upper bound
|
823
|
-
return it.Scan(upper_bound, max_count, result_ids,
|
827
|
+
return it.Scan(upper_bound, max_count, result_ids, equal);
|
824
828
|
}
|
825
829
|
|
826
830
|
//===--------------------------------------------------------------------===//
|
827
831
|
// Closed Range Query
|
828
832
|
//===--------------------------------------------------------------------===//
|
829
833
|
|
830
|
-
bool ART::SearchCloseRange(ARTIndexScanState &state, ARTKey &lower_bound, ARTKey &upper_bound, bool
|
831
|
-
bool
|
832
|
-
|
834
|
+
bool ART::SearchCloseRange(ARTIndexScanState &state, ARTKey &lower_bound, ARTKey &upper_bound, bool left_equal,
|
835
|
+
bool right_equal, idx_t max_count, vector<row_t> &result_ids) {
|
836
|
+
|
837
|
+
Iterator &it = state.iterator;
|
833
838
|
|
834
|
-
//
|
839
|
+
// find the first node that satisfies the left predicate
|
835
840
|
if (!it.art) {
|
836
841
|
it.art = this;
|
837
|
-
if (!it.LowerBound(*tree, lower_bound,
|
842
|
+
if (!it.LowerBound(*tree, lower_bound, left_equal, 0)) {
|
843
|
+
// early-out, if the maximum value in the ART is lower than the lower bound
|
838
844
|
return true;
|
839
845
|
}
|
840
846
|
}
|
841
847
|
|
842
848
|
// now continue the scan until we reach the upper bound
|
843
|
-
return it.Scan(upper_bound, max_count, result_ids,
|
849
|
+
return it.Scan(upper_bound, max_count, result_ids, right_equal);
|
844
850
|
}
|
845
851
|
|
846
|
-
bool ART::Scan(const Transaction &transaction, const DataTable &table, IndexScanState &
|
847
|
-
|
848
|
-
|
852
|
+
bool ART::Scan(const Transaction &transaction, const DataTable &table, IndexScanState &state, const idx_t max_count,
|
853
|
+
vector<row_t> &result_ids) {
|
854
|
+
|
855
|
+
auto &scan_state = state.Cast<ARTIndexScanState>();
|
849
856
|
vector<row_t> row_ids;
|
850
857
|
bool success;
|
851
858
|
|
852
859
|
// FIXME: the key directly owning the data for a single key might be more efficient
|
853
|
-
D_ASSERT(
|
860
|
+
D_ASSERT(scan_state.values[0].type().InternalType() == types[0]);
|
854
861
|
ArenaAllocator arena_allocator(Allocator::Get(db));
|
855
|
-
auto key = CreateKey(arena_allocator, types[0],
|
862
|
+
auto key = CreateKey(arena_allocator, types[0], scan_state.values[0]);
|
856
863
|
|
857
|
-
if (
|
864
|
+
if (scan_state.values[1].IsNull()) {
|
858
865
|
|
859
866
|
// single predicate
|
860
867
|
lock_guard<mutex> l(lock);
|
861
|
-
switch (
|
868
|
+
switch (scan_state.expressions[0]) {
|
862
869
|
case ExpressionType::COMPARE_EQUAL:
|
863
870
|
success = SearchEqual(key, max_count, row_ids);
|
864
871
|
break;
|
865
872
|
case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
|
866
|
-
success = SearchGreater(
|
873
|
+
success = SearchGreater(scan_state, key, true, max_count, row_ids);
|
867
874
|
break;
|
868
875
|
case ExpressionType::COMPARE_GREATERTHAN:
|
869
|
-
success = SearchGreater(
|
876
|
+
success = SearchGreater(scan_state, key, false, max_count, row_ids);
|
870
877
|
break;
|
871
878
|
case ExpressionType::COMPARE_LESSTHANOREQUALTO:
|
872
|
-
success = SearchLess(
|
879
|
+
success = SearchLess(scan_state, key, true, max_count, row_ids);
|
873
880
|
break;
|
874
881
|
case ExpressionType::COMPARE_LESSTHAN:
|
875
|
-
success = SearchLess(
|
882
|
+
success = SearchLess(scan_state, key, false, max_count, row_ids);
|
876
883
|
break;
|
877
884
|
default:
|
878
|
-
throw InternalException("
|
885
|
+
throw InternalException("Index scan type not implemented");
|
879
886
|
}
|
880
887
|
|
881
888
|
} else {
|
@@ -883,12 +890,12 @@ bool ART::Scan(const Transaction &transaction, const DataTable &table, IndexScan
|
|
883
890
|
// two predicates
|
884
891
|
lock_guard<mutex> l(lock);
|
885
892
|
|
886
|
-
D_ASSERT(
|
887
|
-
auto upper_bound = CreateKey(arena_allocator, types[0],
|
893
|
+
D_ASSERT(scan_state.values[1].type().InternalType() == types[0]);
|
894
|
+
auto upper_bound = CreateKey(arena_allocator, types[0], scan_state.values[1]);
|
888
895
|
|
889
|
-
bool
|
890
|
-
bool
|
891
|
-
success = SearchCloseRange(
|
896
|
+
bool left_equal = scan_state.expressions[0] == ExpressionType ::COMPARE_GREATERTHANOREQUALTO;
|
897
|
+
bool right_equal = scan_state.expressions[1] == ExpressionType ::COMPARE_LESSTHANOREQUALTO;
|
898
|
+
success = SearchCloseRange(scan_state, key, upper_bound, left_equal, right_equal, max_count, row_ids);
|
892
899
|
}
|
893
900
|
|
894
901
|
if (!success) {
|
@@ -1136,6 +1143,9 @@ bool ART::MergeIndexes(IndexLock &state, Index &other_index) {
|
|
1136
1143
|
//===--------------------------------------------------------------------===//
|
1137
1144
|
|
1138
1145
|
string ART::VerifyAndToString(IndexLock &state, const bool only_verify) {
|
1146
|
+
// FIXME: this can be improved by counting the allocations of each node type,
|
1147
|
+
// FIXME: and by asserting that each fixed-size allocator lists an equal number of
|
1148
|
+
// FIXME: allocations of that type
|
1139
1149
|
return VerifyAndToStringInternal(only_verify);
|
1140
1150
|
}
|
1141
1151
|
|
@@ -114,7 +114,7 @@ void FixedSizeAllocator::Merge(FixedSizeAllocator &other) {
|
|
114
114
|
}
|
115
115
|
other.buffers.clear();
|
116
116
|
|
117
|
-
// merge the
|
117
|
+
// merge the buffers with free spaces
|
118
118
|
for (auto &buffer_id : other.buffers_with_free_space) {
|
119
119
|
buffers_with_free_space.insert(buffer_id + buffer_count);
|
120
120
|
}
|