duckdb 1.0.1-dev22.0 → 1.0.1-dev27.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/.github/workflows/NodeJS.yml +1 -1
- package/binding.gyp +41 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +4 -2
- package/src/duckdb/extension/icu/icu-datefunc.cpp +6 -2
- package/src/duckdb/extension/icu/icu-datesub.cpp +13 -2
- package/src/duckdb/extension/icu/icu-strptime.cpp +6 -6
- package/src/duckdb/extension/icu/icu-table-range.cpp +92 -73
- package/src/duckdb/extension/icu/icu-timebucket.cpp +12 -2
- package/src/duckdb/extension/icu/icu-timezone.cpp +3 -3
- package/src/duckdb/extension/icu/icu_extension.cpp +61 -9
- package/src/duckdb/extension/json/include/json_executors.hpp +20 -23
- package/src/duckdb/extension/json/include/json_functions.hpp +4 -0
- package/src/duckdb/extension/json/include/json_scan.hpp +6 -2
- package/src/duckdb/extension/json/include/json_structure.hpp +12 -9
- package/src/duckdb/extension/json/json_common.cpp +66 -10
- package/src/duckdb/extension/json/json_extension.cpp +13 -5
- package/src/duckdb/extension/json/json_functions/json_array_length.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_create.cpp +21 -4
- package/src/duckdb/extension/json/json_functions/json_exists.cpp +32 -0
- package/src/duckdb/extension/json/json_functions/json_extract.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_keys.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_pretty.cpp +32 -0
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +5 -1
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +305 -94
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_type.cpp +3 -3
- package/src/duckdb/extension/json/json_functions/json_value.cpp +42 -0
- package/src/duckdb/extension/json/json_functions/read_json.cpp +16 -2
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +3 -2
- package/src/duckdb/extension/json/json_functions.cpp +5 -1
- package/src/duckdb/extension/json/json_scan.cpp +13 -12
- package/src/duckdb/extension/json/serialize_json.cpp +5 -3
- package/src/duckdb/extension/parquet/column_reader.cpp +206 -43
- package/src/duckdb/extension/parquet/column_writer.cpp +133 -62
- package/src/duckdb/extension/parquet/geo_parquet.cpp +391 -0
- package/src/duckdb/extension/parquet/include/boolean_column_reader.hpp +16 -5
- package/src/duckdb/extension/parquet/include/column_reader.hpp +37 -12
- package/src/duckdb/extension/parquet/include/column_writer.hpp +10 -11
- package/src/duckdb/extension/parquet/include/expression_column_reader.hpp +52 -0
- package/src/duckdb/extension/parquet/include/geo_parquet.hpp +139 -0
- package/src/duckdb/extension/parquet/include/parquet_crypto.hpp +13 -8
- package/src/duckdb/extension/parquet/include/parquet_decimal_utils.hpp +3 -0
- package/src/duckdb/extension/parquet/include/parquet_file_metadata_cache.hpp +7 -3
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +55 -8
- package/src/duckdb/extension/parquet/include/parquet_rle_bp_decoder.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_rle_bp_encoder.hpp +1 -1
- package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +8 -0
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +21 -7
- package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +33 -11
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +5 -2
- package/src/duckdb/extension/parquet/include/templated_column_reader.hpp +48 -14
- package/src/duckdb/extension/parquet/parquet_crypto.cpp +109 -61
- package/src/duckdb/extension/parquet/parquet_extension.cpp +305 -72
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +4 -4
- package/src/duckdb/extension/parquet/parquet_reader.cpp +151 -40
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +50 -16
- package/src/duckdb/extension/parquet/parquet_timestamp.cpp +42 -1
- package/src/duckdb/extension/parquet/parquet_writer.cpp +67 -75
- package/src/duckdb/extension/parquet/serialize_parquet.cpp +3 -1
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +5 -1
- package/src/duckdb/src/catalog/catalog.cpp +14 -16
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +14 -11
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +39 -19
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +92 -78
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +10 -2
- package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +10 -3
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +7 -7
- package/src/duckdb/src/catalog/catalog_entry.cpp +6 -3
- package/src/duckdb/src/catalog/catalog_set.cpp +14 -19
- package/src/duckdb/src/catalog/default/default_functions.cpp +179 -166
- package/src/duckdb/src/catalog/default/default_generator.cpp +24 -0
- package/src/duckdb/src/catalog/default/default_schemas.cpp +4 -3
- package/src/duckdb/src/catalog/default/default_table_functions.cpp +148 -0
- package/src/duckdb/src/catalog/default/default_views.cpp +7 -3
- package/src/duckdb/src/catalog/duck_catalog.cpp +7 -1
- package/src/duckdb/src/common/adbc/adbc.cpp +120 -58
- package/src/duckdb/src/common/allocator.cpp +71 -6
- package/src/duckdb/src/common/arrow/appender/bool_data.cpp +8 -7
- package/src/duckdb/src/common/arrow/appender/fixed_size_list_data.cpp +1 -1
- package/src/duckdb/src/common/arrow/appender/union_data.cpp +4 -5
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +55 -21
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +85 -10
- package/src/duckdb/src/common/arrow/arrow_merge_event.cpp +142 -0
- package/src/duckdb/src/common/arrow/arrow_query_result.cpp +56 -0
- package/src/duckdb/src/common/arrow/physical_arrow_batch_collector.cpp +37 -0
- package/src/duckdb/src/common/arrow/physical_arrow_collector.cpp +128 -0
- package/src/duckdb/src/common/arrow/schema_metadata.cpp +101 -0
- package/src/duckdb/src/common/cgroups.cpp +189 -0
- package/src/duckdb/src/common/compressed_file_system.cpp +6 -3
- package/src/duckdb/src/common/encryption_state.cpp +38 -0
- package/src/duckdb/src/common/enum_util.cpp +682 -14
- package/src/duckdb/src/common/enums/file_compression_type.cpp +24 -0
- package/src/duckdb/src/common/enums/metric_type.cpp +208 -0
- package/src/duckdb/src/common/enums/optimizer_type.cpp +8 -2
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/relation_type.cpp +4 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +15 -0
- package/src/duckdb/src/common/error_data.cpp +22 -20
- package/src/duckdb/src/common/exception/binder_exception.cpp +5 -0
- package/src/duckdb/src/common/exception.cpp +11 -1
- package/src/duckdb/src/common/extra_type_info.cpp +3 -0
- package/src/duckdb/src/common/file_buffer.cpp +1 -1
- package/src/duckdb/src/common/file_system.cpp +25 -3
- package/src/duckdb/src/common/filename_pattern.cpp +1 -0
- package/src/duckdb/src/common/fsst.cpp +15 -14
- package/src/duckdb/src/common/gzip_file_system.cpp +3 -1
- package/src/duckdb/src/common/hive_partitioning.cpp +103 -43
- package/src/duckdb/src/common/http_util.cpp +25 -0
- package/src/duckdb/src/common/local_file_system.cpp +48 -27
- package/src/duckdb/src/common/multi_file_list.cpp +113 -22
- package/src/duckdb/src/common/multi_file_reader.cpp +59 -58
- package/src/duckdb/src/common/operator/cast_operators.cpp +133 -34
- package/src/duckdb/src/common/operator/string_cast.cpp +42 -11
- package/src/duckdb/src/common/progress_bar/progress_bar.cpp +2 -2
- package/src/duckdb/src/common/progress_bar/terminal_progress_bar_display.cpp +1 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +31 -21
- package/src/duckdb/src/common/random_engine.cpp +4 -0
- package/src/duckdb/src/common/re2_regex.cpp +47 -12
- package/src/duckdb/src/common/render_tree.cpp +243 -0
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
- package/src/duckdb/src/common/row_operations/row_matcher.cpp +58 -5
- package/src/duckdb/src/common/row_operations/row_radix_scatter.cpp +79 -43
- package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +6 -4
- package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +18 -9
- package/src/duckdb/src/common/serializer/memory_stream.cpp +1 -0
- package/src/duckdb/src/common/sort/partition_state.cpp +33 -18
- package/src/duckdb/src/common/sort/radix_sort.cpp +22 -15
- package/src/duckdb/src/common/sort/sort_state.cpp +19 -16
- package/src/duckdb/src/common/sort/sorted_block.cpp +11 -10
- package/src/duckdb/src/common/string_util.cpp +167 -10
- package/src/duckdb/src/common/tree_renderer/graphviz_tree_renderer.cpp +108 -0
- package/src/duckdb/src/common/tree_renderer/html_tree_renderer.cpp +267 -0
- package/src/duckdb/src/common/tree_renderer/json_tree_renderer.cpp +116 -0
- package/src/duckdb/src/common/tree_renderer/text_tree_renderer.cpp +482 -0
- package/src/duckdb/src/common/tree_renderer/tree_renderer.cpp +12 -0
- package/src/duckdb/src/common/tree_renderer.cpp +16 -508
- package/src/duckdb/src/common/types/batched_data_collection.cpp +78 -9
- package/src/duckdb/src/common/types/bit.cpp +24 -22
- package/src/duckdb/src/common/types/blob.cpp +15 -11
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +18 -9
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +4 -4
- package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +3 -4
- package/src/duckdb/src/common/types/column/column_data_consumer.cpp +2 -2
- package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +70 -21
- package/src/duckdb/src/common/types/data_chunk.cpp +10 -1
- package/src/duckdb/src/common/types/date.cpp +8 -19
- package/src/duckdb/src/common/types/decimal.cpp +3 -2
- package/src/duckdb/src/common/types/hugeint.cpp +11 -3
- package/src/duckdb/src/common/types/hyperloglog.cpp +212 -227
- package/src/duckdb/src/common/types/interval.cpp +1 -1
- package/src/duckdb/src/common/types/list_segment.cpp +83 -49
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +22 -83
- package/src/duckdb/src/common/types/row/row_data_collection.cpp +2 -2
- package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +20 -4
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +28 -7
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +29 -14
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +152 -102
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +4 -1
- package/src/duckdb/src/common/types/selection_vector.cpp +17 -1
- package/src/duckdb/src/common/types/time.cpp +62 -31
- package/src/duckdb/src/common/types/timestamp.cpp +70 -12
- package/src/duckdb/src/common/types/uuid.cpp +1 -1
- package/src/duckdb/src/common/types/validity_mask.cpp +40 -5
- package/src/duckdb/src/common/types/value.cpp +50 -8
- package/src/duckdb/src/common/types/varint.cpp +295 -0
- package/src/duckdb/src/common/types/vector.cpp +165 -54
- package/src/duckdb/src/common/types/vector_buffer.cpp +5 -4
- package/src/duckdb/src/common/types.cpp +106 -26
- package/src/duckdb/src/common/vector_operations/vector_copy.cpp +13 -25
- package/src/duckdb/src/common/vector_operations/vector_hash.cpp +6 -0
- package/src/duckdb/src/common/virtual_file_system.cpp +3 -3
- package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +35 -82
- package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +283 -46
- package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +3 -2
- package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +226 -338
- package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +2 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/approx_top_k.cpp +388 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +63 -21
- package/src/duckdb/src/core_functions/aggregate/holistic/mad.cpp +330 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +136 -97
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +601 -1485
- package/src/duckdb/src/core_functions/aggregate/nested/binned_histogram.cpp +405 -0
- package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +136 -165
- package/src/duckdb/src/core_functions/function_list.cpp +35 -8
- package/src/duckdb/src/core_functions/lambda_functions.cpp +5 -7
- package/src/duckdb/src/core_functions/scalar/array/array_functions.cpp +172 -198
- package/src/duckdb/src/core_functions/scalar/blob/create_sort_key.cpp +341 -54
- package/src/duckdb/src/core_functions/scalar/date/date_diff.cpp +2 -2
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +89 -29
- package/src/duckdb/src/core_functions/scalar/date/date_trunc.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +2 -2
- package/src/duckdb/src/core_functions/scalar/date/strftime.cpp +133 -71
- package/src/duckdb/src/core_functions/scalar/date/to_interval.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/enum/enum_functions.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/generic/can_implicitly_cast.cpp +40 -0
- package/src/duckdb/src/core_functions/scalar/generic/error.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/generic/least.cpp +161 -58
- package/src/duckdb/src/core_functions/scalar/generic/typeof.cpp +13 -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 +59 -75
- package/src/duckdb/src/core_functions/scalar/list/list_distance.cpp +93 -40
- package/src/duckdb/src/core_functions/scalar/list/list_has_any_or_all.cpp +227 -0
- package/src/duckdb/src/core_functions/scalar/list/list_reduce.cpp +20 -19
- package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +0 -2
- package/src/duckdb/src/core_functions/scalar/list/list_value.cpp +106 -8
- package/src/duckdb/src/core_functions/scalar/map/map_contains.cpp +56 -0
- package/src/duckdb/src/core_functions/scalar/map/map_extract.cpp +73 -118
- package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +98 -2
- package/src/duckdb/src/core_functions/scalar/operators/bitwise.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/random/setseed.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/string/bar.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/string/hex.cpp +5 -1
- package/src/duckdb/src/core_functions/scalar/string/md5.cpp +10 -37
- package/src/duckdb/src/core_functions/scalar/string/printf.cpp +18 -2
- package/src/duckdb/src/core_functions/scalar/string/repeat.cpp +45 -0
- package/src/duckdb/src/core_functions/scalar/string/reverse.cpp +4 -5
- package/src/duckdb/src/core_functions/scalar/string/sha1.cpp +35 -0
- package/src/duckdb/src/core_functions/scalar/string/sha256.cpp +5 -2
- package/src/duckdb/src/core_functions/scalar/string/url_encode.cpp +49 -0
- package/src/duckdb/src/core_functions/scalar/struct/struct_pack.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/union/union_extract.cpp +4 -2
- package/src/duckdb/src/execution/adaptive_filter.cpp +30 -11
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +13 -18
- package/src/duckdb/src/execution/expression_executor/execute_conjunction.cpp +4 -9
- package/src/duckdb/src/execution/expression_executor.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +683 -670
- package/src/duckdb/src/execution/index/art/art_key.cpp +121 -38
- package/src/duckdb/src/execution/index/art/base_leaf.cpp +168 -0
- package/src/duckdb/src/execution/index/art/base_node.cpp +163 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +148 -77
- package/src/duckdb/src/execution/index/art/leaf.cpp +159 -263
- package/src/duckdb/src/execution/index/art/node.cpp +493 -247
- package/src/duckdb/src/execution/index/art/node256.cpp +31 -91
- package/src/duckdb/src/execution/index/art/node256_leaf.cpp +71 -0
- package/src/duckdb/src/execution/index/art/node48.cpp +75 -143
- package/src/duckdb/src/execution/index/art/prefix.cpp +424 -244
- package/src/duckdb/src/execution/index/bound_index.cpp +7 -1
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +22 -18
- package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +22 -73
- package/src/duckdb/src/execution/join_hashtable.cpp +637 -179
- package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +4 -4
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +15 -10
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +13 -8
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +525 -132
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +147 -138
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +531 -312
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer.cpp +1 -1
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.cpp +4 -3
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_file_handle.cpp +9 -2
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/base_scanner.cpp +13 -17
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +60 -16
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/csv_schema.cpp +105 -0
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/scanner_boundary.cpp +24 -24
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/skip_scanner.cpp +25 -2
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +275 -112
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +106 -11
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +253 -115
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +93 -52
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +116 -76
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_refinement.cpp +29 -14
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +1 -1
- package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +70 -26
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/csv_file_scanner.cpp +81 -60
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/global_csv_state.cpp +88 -50
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +161 -51
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +59 -17
- package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +5 -5
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +0 -21
- package/src/duckdb/src/execution/operator/helper/physical_buffered_batch_collector.cpp +109 -0
- package/src/duckdb/src/execution/operator/helper/physical_buffered_collector.cpp +5 -13
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_load.cpp +12 -4
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +0 -16
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -0
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +3 -1
- package/src/duckdb/src/execution/operator/helper/physical_set_variable.cpp +39 -0
- package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +16 -5
- package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +5 -4
- package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +59 -21
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +7 -4
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +333 -176
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +57 -34
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +16 -8
- package/src/duckdb/src/execution/operator/join/physical_left_delim_join.cpp +10 -4
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +2 -5
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_right_delim_join.cpp +7 -2
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +17 -12
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +12 -9
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +35 -17
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +17 -11
- package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +5 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +156 -47
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +10 -2
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +1 -3
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +2 -2
- package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +13 -6
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +22 -3
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +19 -3
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +37 -22
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +77 -21
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +27 -55
- package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +41 -44
- package/src/duckdb/src/execution/operator/set/physical_cte.cpp +4 -6
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +4 -6
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +18 -4
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +3 -2
- package/src/duckdb/src/execution/physical_operator.cpp +45 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +18 -7
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +8 -3
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +13 -6
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_get.cpp +111 -19
- package/src/duckdb/src/execution/physical_plan/plan_limit.cpp +19 -2
- package/src/duckdb/src/execution/physical_plan/plan_set.cpp +9 -0
- package/src/duckdb/src/execution/physical_plan/plan_window.cpp +3 -1
- package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -3
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +49 -49
- package/src/duckdb/src/execution/reservoir_sample.cpp +2 -2
- package/src/duckdb/src/execution/window_executor.cpp +556 -318
- package/src/duckdb/src/execution/window_segment_tree.cpp +1058 -485
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +5 -5
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +92 -95
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +10 -9
- package/src/duckdb/src/function/aggregate_function.cpp +8 -0
- package/src/duckdb/src/function/cast/cast_function_set.cpp +10 -1
- package/src/duckdb/src/function/cast/decimal_cast.cpp +10 -1
- package/src/duckdb/src/function/cast/default_casts.cpp +2 -0
- package/src/duckdb/src/function/cast/numeric_casts.cpp +3 -0
- package/src/duckdb/src/function/cast/string_cast.cpp +8 -5
- package/src/duckdb/src/function/cast/time_casts.cpp +2 -2
- package/src/duckdb/src/function/cast/union_casts.cpp +1 -1
- package/src/duckdb/src/function/cast/varint_casts.cpp +283 -0
- package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +3 -1
- package/src/duckdb/src/function/cast_rules.cpp +104 -15
- package/src/duckdb/src/function/compression_config.cpp +35 -33
- package/src/duckdb/src/function/copy_function.cpp +27 -0
- package/src/duckdb/src/function/function_binder.cpp +39 -11
- package/src/duckdb/src/function/macro_function.cpp +75 -32
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +1 -0
- package/src/duckdb/src/function/scalar/generic/binning.cpp +507 -0
- package/src/duckdb/src/function/scalar/generic/getvariable.cpp +58 -0
- package/src/duckdb/src/function/scalar/generic_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +33 -47
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +70 -143
- package/src/duckdb/src/function/scalar/list/list_resize.cpp +93 -84
- package/src/duckdb/src/function/scalar/list/list_zip.cpp +3 -0
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +24 -11
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +4 -4
- package/src/duckdb/src/function/scalar/strftime_format.cpp +196 -57
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +9 -7
- package/src/duckdb/src/function/scalar/string/concat.cpp +239 -123
- package/src/duckdb/src/function/scalar/string/concat_ws.cpp +149 -0
- package/src/duckdb/src/function/scalar/string/contains.cpp +18 -7
- package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/substring.cpp +6 -11
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +7 -3
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
- package/src/duckdb/src/function/scalar_function.cpp +5 -2
- package/src/duckdb/src/function/scalar_macro_function.cpp +2 -2
- package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +20 -39
- package/src/duckdb/src/function/table/arrow/arrow_type_info.cpp +135 -0
- package/src/duckdb/src/function/table/arrow.cpp +194 -52
- package/src/duckdb/src/function/table/arrow_conversion.cpp +212 -69
- package/src/duckdb/src/function/table/copy_csv.cpp +43 -14
- package/src/duckdb/src/function/table/query_function.cpp +80 -0
- package/src/duckdb/src/function/table/range.cpp +222 -142
- package/src/duckdb/src/function/table/read_csv.cpp +25 -13
- package/src/duckdb/src/function/table/sniff_csv.cpp +55 -35
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +141 -129
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +25 -14
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +20 -14
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +15 -1
- package/src/duckdb/src/function/table/system/duckdb_variables.cpp +84 -0
- package/src/duckdb/src/function/table/system/test_all_types.cpp +1 -0
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +33 -3
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +45 -22
- package/src/duckdb/src/function/table/unnest.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -4
- package/src/duckdb/src/function/table_function.cpp +5 -4
- package/src/duckdb/src/function/table_macro_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +8 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +5 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +3 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +5 -5
- package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/default/default_generator.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/default/default_schemas.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/default/default_table_functions.hpp +47 -0
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +9 -1
- package/src/duckdb/src/include/duckdb/common/array_ptr.hpp +120 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/append_data.hpp +37 -11
- package/src/duckdb/src/include/duckdb/common/arrow/appender/enum_data.hpp +9 -8
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_data.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_view_data.hpp +92 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/map_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/arrow/appender/scalar_data.hpp +26 -4
- package/src/duckdb/src/include/duckdb/common/arrow/appender/varchar_data.hpp +90 -11
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +6 -6
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_buffer.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_merge_event.hpp +62 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_query_result.hpp +52 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_types_extension.hpp +42 -0
- package/src/duckdb/src/include/duckdb/common/arrow/physical_arrow_batch_collector.hpp +30 -0
- package/src/duckdb/src/include/duckdb/common/arrow/physical_arrow_collector.hpp +65 -0
- package/src/duckdb/src/include/duckdb/common/arrow/schema_metadata.hpp +43 -0
- package/src/duckdb/src/include/duckdb/common/bswap.hpp +18 -16
- package/src/duckdb/src/include/duckdb/common/cgroups.hpp +30 -0
- package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/dl.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/encryption_state.hpp +48 -0
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +88 -0
- package/src/duckdb/src/include/duckdb/common/enums/checkpoint_type.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/copy_overwrite_mode.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/enums/destroy_buffer_upon.hpp +21 -0
- package/src/duckdb/src/include/duckdb/common/enums/explain_format.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/enums/file_compression_type.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/enums/join_type.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/metric_type.hpp +88 -0
- package/src/duckdb/src/include/duckdb/common/enums/optimizer_type.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/enums/pending_execution_result.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/profiler_format.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/enums/relation_type.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/enums/set_scope.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +23 -2
- package/src/duckdb/src/include/duckdb/common/enums/stream_execution_result.hpp +25 -0
- package/src/duckdb/src/include/duckdb/common/enums/tableref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/wal_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/error_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/exception/binder_exception.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +20 -2
- package/src/duckdb/src/include/duckdb/common/extra_operator_info.hpp +12 -0
- package/src/duckdb/src/include/duckdb/common/file_buffer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/file_open_flags.hpp +16 -0
- package/src/duckdb/src/include/duckdb/common/file_opener.hpp +18 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/fixed_size_map.hpp +160 -96
- package/src/duckdb/src/include/duckdb/common/fsst.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -8
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +16 -7
- package/src/duckdb/src/include/duckdb/common/http_util.hpp +19 -0
- package/src/duckdb/src/include/duckdb/common/insertion_order_preserving_map.hpp +19 -6
- package/src/duckdb/src/include/duckdb/common/limits.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/multi_file_list.hpp +38 -6
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +82 -50
- package/src/duckdb/src/include/duckdb/common/operator/abs.hpp +11 -0
- package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +7 -3
- package/src/duckdb/src/include/duckdb/common/operator/decimal_cast_operators.hpp +23 -1
- package/src/duckdb/src/include/duckdb/common/operator/double_cast_operator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/operator/integer_cast_operator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/operator/numeric_cast.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/operator/string_cast.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +10 -5
- package/src/duckdb/src/include/duckdb/common/optionally_owned_ptr.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/owning_string_map.hpp +155 -0
- package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/platform.hpp +58 -0
- package/src/duckdb/src/include/duckdb/common/radix.hpp +172 -27
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/random_engine.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/re2_regex.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/render_tree.hpp +77 -0
- package/src/duckdb/src/include/duckdb/common/row_operations/row_matcher.hpp +12 -0
- package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +6 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +15 -7
- package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_data.hpp +245 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +10 -11
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +12 -6
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +37 -7
- package/src/duckdb/src/include/duckdb/common/tree_renderer/graphviz_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/html_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/json_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/text_tree_renderer.hpp +119 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer.hpp +9 -123
- package/src/duckdb/src/include/duckdb/common/type_visitor.hpp +96 -0
- package/src/duckdb/src/include/duckdb/common/typedefs.hpp +11 -1
- package/src/duckdb/src/include/duckdb/common/types/arrow_string_view_type.hpp +84 -0
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +36 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/cast_helpers.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/types/column/partitioned_column_data.hpp +52 -0
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/date.hpp +0 -3
- package/src/duckdb/src/include/duckdb/common/types/date_lookup_cache.hpp +65 -0
- package/src/duckdb/src/include/duckdb/common/types/datetime.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/types/hyperloglog.hpp +49 -40
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +41 -9
- package/src/duckdb/src/include/duckdb/common/types/row/row_data_collection.hpp +4 -3
- package/src/duckdb/src/include/duckdb/common/types/row/row_data_collection_scanner.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +4 -1
- package/src/duckdb/src/include/duckdb/common/types/time.hpp +11 -6
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +13 -3
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +103 -12
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +12 -3
- package/src/duckdb/src/include/duckdb/common/types/varint.hpp +107 -0
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +7 -2
- package/src/duckdb/src/include/duckdb/common/types.hpp +6 -39
- package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +42 -10
- package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +29 -0
- package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +0 -7
- package/src/duckdb/src/include/duckdb/common/vector_operations/vector_operations.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/winapi.hpp +8 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +8 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +8 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +4 -2
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/histogram_helpers.hpp +99 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/holistic_functions.hpp +16 -7
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/minmax_n_helpers.hpp +396 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/nested_functions.hpp +10 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_helpers.hpp +65 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_sort_tree.hpp +349 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_state.hpp +300 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +1 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/sort_key_helpers.hpp +55 -0
- package/src/duckdb/src/include/duckdb/core_functions/array_kernels.hpp +107 -0
- package/src/duckdb/src/include/duckdb/core_functions/create_sort_key.hpp +55 -0
- package/src/duckdb/src/include/duckdb/core_functions/lambda_functions.hpp +1 -2
- package/src/duckdb/src/include/duckdb/core_functions/scalar/array_functions.hpp +24 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +27 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +80 -8
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/math_functions.hpp +54 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +30 -21
- package/src/duckdb/src/include/duckdb/execution/adaptive_filter.hpp +25 -14
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +2 -48
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +25 -2
- package/src/duckdb/src/include/duckdb/execution/ht_entry.hpp +102 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +94 -101
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +43 -25
- package/src/duckdb/src/include/duckdb/execution/index/art/base_leaf.hpp +109 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/base_node.hpp +140 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +43 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +41 -52
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +133 -74
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +46 -29
- package/src/duckdb/src/include/duckdb/execution/index/art/node256_leaf.hpp +53 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +96 -57
- package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +9 -4
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +48 -10
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/index/index_pointer.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +114 -36
- package/src/duckdb/src/include/duckdb/execution/merge_sort_tree.hpp +158 -67
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/aggregate_object.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp +19 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/ungrouped_aggregate_state.hpp +75 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +81 -23
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +27 -8
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_error.hpp +31 -22
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_handle.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_scanner.hpp +48 -5
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_option.hpp +7 -3
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_reader_options.hpp +22 -12
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_schema.hpp +35 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_sniffer.hpp +81 -39
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp +18 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine_cache.hpp +9 -7
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/global_csv_state.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/header_value.hpp +26 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner_boundary.hpp +6 -9
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/skip_scanner.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +5 -3
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +36 -19
- package/src/duckdb/src/include/duckdb/execution/operator/filter/physical_filter.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +21 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_buffered_batch_collector.hpp +53 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_buffered_collector.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +6 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +18 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +6 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set_variable.hpp +43 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_sample.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/join_filter_pushdown.hpp +59 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_comparison_join.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +5 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_left_delim_join.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +4 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_right_delim_join.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/batch_memory_manager.hpp +5 -37
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +8 -2
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_projection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_tableinout_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +9 -3
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +8 -6
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_art_index.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +21 -6
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/window_executor.hpp +137 -110
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +57 -126
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +21 -4
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/compression/compression.hpp +10 -10
- package/src/duckdb/src/include/duckdb/function/compression_function.hpp +37 -7
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +24 -11
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +41 -1
- package/src/duckdb/src/include/duckdb/function/macro_function.hpp +15 -5
- package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/replacement_scan.hpp +20 -4
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +6 -0
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +77 -109
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +6 -3
- package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +25 -12
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +9 -8
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +38 -4
- package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +11 -57
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_type_info.hpp +142 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_datetime_type.hpp +18 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_type_info_type.hpp +7 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_variable_size_type.hpp +10 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/table/range.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +4 -1
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -5
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +14 -2
- package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/appender.hpp +14 -4
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +25 -7
- package/src/duckdb/src/include/duckdb/main/buffered_data/batched_buffered_data.hpp +79 -0
- package/src/duckdb/src/include/duckdb/main/buffered_data/buffered_data.hpp +10 -20
- package/src/duckdb/src/include/duckdb/main/buffered_data/simple_buffered_data.hpp +11 -12
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +7 -2
- package/src/duckdb/src/include/duckdb/main/capi/cast/generic.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/capi/cast/utils.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/capi/extension_api.hpp +809 -0
- package/src/duckdb/src/include/duckdb/main/chunk_scan_state/batched_data_collection.hpp +35 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +68 -2
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +30 -22
- package/src/duckdb/src/include/duckdb/main/client_context_state.hpp +79 -1
- package/src/duckdb/src/include/duckdb/main/client_properties.hpp +9 -3
- package/src/duckdb/src/include/duckdb/main/config.hpp +55 -7
- package/src/duckdb/src/include/duckdb/main/connection.hpp +5 -1
- package/src/duckdb/src/include/duckdb/main/database.hpp +16 -5
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +9 -8
- package/src/duckdb/src/include/duckdb/main/db_instance_cache.hpp +21 -6
- package/src/duckdb/src/include/duckdb/main/extension.hpp +20 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +25 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +29 -23
- package/src/duckdb/src/include/duckdb/main/extension_install_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/extension_util.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/pending_query_result.hpp +4 -2
- package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +5 -6
- package/src/duckdb/src/include/duckdb/main/prepared_statement_data.hpp +2 -5
- package/src/duckdb/src/include/duckdb/main/profiling_info.hpp +87 -0
- package/src/duckdb/src/include/duckdb/main/profiling_node.hpp +60 -0
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +72 -34
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/relation/create_table_relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/relation/delim_get_relation.hpp +30 -0
- package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/relation/join_relation.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/relation/materialized_relation.hpp +1 -4
- package/src/duckdb/src/include/duckdb/main/relation/query_relation.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/relation/read_json_relation.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/relation/table_function_relation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/relation/view_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation.hpp +7 -4
- package/src/duckdb/src/include/duckdb/main/secret/default_secrets.hpp +36 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +108 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +14 -4
- package/src/duckdb/src/include/duckdb/main/settings.hpp +227 -3
- package/src/duckdb/src/include/duckdb/main/stream_query_result.hpp +8 -0
- package/src/duckdb/src/include/duckdb/optimizer/build_probe_side_optimizer.hpp +51 -0
- package/src/duckdb/src/include/duckdb/optimizer/compressed_materialization.hpp +7 -0
- package/src/duckdb/src/include/duckdb/optimizer/cte_filter_pusher.hpp +46 -0
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +7 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_filter_pushdown_optimizer.hpp +31 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +51 -10
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cost_model.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +17 -5
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph_manager.hpp +15 -13
- package/src/duckdb/src/include/duckdb/optimizer/join_order/relation_manager.hpp +9 -4
- package/src/duckdb/src/include/duckdb/optimizer/limit_pushdown.hpp +25 -0
- package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/join_dependent_filter.hpp +37 -0
- package/src/duckdb/src/include/duckdb/parallel/executor_task.hpp +6 -1
- package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +54 -2
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +27 -8
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline_prepare_finish_event.hpp +25 -0
- package/src/duckdb/src/include/duckdb/parallel/task_executor.hpp +63 -0
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +10 -1
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +11 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_expression_iterator.hpp +13 -6
- package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +1 -3
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/statement/explain_statement.hpp +5 -1
- package/src/duckdb/src/include/duckdb/parser/statement/set_statement.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/transaction_statement.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/column_data_ref.hpp +9 -7
- package/src/duckdb/src/include/duckdb/parser/tableref/delimgetref.hpp +37 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +0 -1
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +17 -9
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +24 -14
- package/src/duckdb/src/include/duckdb/planner/collation_binding.hpp +44 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_expanded_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/column_alias_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/group_binder.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +6 -5
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +19 -11
- package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/filter/null_filter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/filter/struct_filter.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +7 -2
- package/src/duckdb/src/include/duckdb/planner/logical_operator_visitor.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +6 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +10 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +4 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +15 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +24 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_delimgetref.hpp +26 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_joinref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_subqueryref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_table_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/list.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/block.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +48 -3
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +21 -7
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +65 -51
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +14 -5
- package/src/duckdb/src/include/duckdb/storage/checkpoint/row_group_writer.hpp +0 -4
- package/src/duckdb/src/include/duckdb/storage/checkpoint/string_checkpoint_state.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint/write_overflow_strings_to_disk.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/compression/alp/algorithm/alp.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_analyze.hpp +6 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_compress.hpp +19 -17
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_constants.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_utils.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/algorithm/alprd.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_analyze.hpp +13 -11
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_compress.hpp +19 -19
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +15 -0
- package/src/duckdb/src/include/duckdb/storage/index_storage_info.hpp +14 -10
- package/src/duckdb/src/include/duckdb/storage/metadata/metadata_manager.hpp +6 -8
- package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +7 -4
- package/src/duckdb/src/include/duckdb/storage/segment/uncompressed.hpp +4 -7
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +29 -4
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +22 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +15 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +8 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +5 -16
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +51 -13
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +29 -19
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +23 -7
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +27 -18
- package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/table/array_column_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +5 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +77 -6
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +23 -11
- package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +18 -4
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +7 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_version_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +89 -14
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/temporary_memory_manager.hpp +33 -15
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -9
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -1
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +4 -16
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +27 -4
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction_manager.hpp +11 -0
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +6 -2
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +5 -5
- package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +6 -2
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/transaction/wal_write_state.hpp +48 -0
- package/src/duckdb/src/include/duckdb.h +1779 -739
- package/src/duckdb/src/include/duckdb_extension.h +921 -0
- package/src/duckdb/src/main/appender.cpp +53 -7
- package/src/duckdb/src/main/attached_database.cpp +87 -17
- package/src/duckdb/src/main/buffered_data/batched_buffered_data.cpp +226 -0
- package/src/duckdb/src/main/buffered_data/buffered_data.cpp +35 -0
- package/src/duckdb/src/main/buffered_data/simple_buffered_data.cpp +48 -23
- package/src/duckdb/src/main/capi/aggregate_function-c.cpp +327 -0
- package/src/duckdb/src/main/capi/appender-c.cpp +18 -0
- package/src/duckdb/src/main/capi/cast/utils-c.cpp +2 -2
- package/src/duckdb/src/main/capi/cast_function-c.cpp +210 -0
- package/src/duckdb/src/main/capi/config-c.cpp +3 -3
- package/src/duckdb/src/main/capi/data_chunk-c.cpp +18 -7
- package/src/duckdb/src/main/capi/duckdb_value-c.cpp +223 -24
- package/src/duckdb/src/main/capi/helper-c.cpp +51 -11
- package/src/duckdb/src/main/capi/logical_types-c.cpp +105 -46
- package/src/duckdb/src/main/capi/pending-c.cpp +7 -6
- package/src/duckdb/src/main/capi/prepared-c.cpp +18 -7
- package/src/duckdb/src/main/capi/profiling_info-c.cpp +84 -0
- package/src/duckdb/src/main/capi/result-c.cpp +139 -37
- package/src/duckdb/src/main/capi/scalar_function-c.cpp +269 -0
- package/src/duckdb/src/main/capi/table_description-c.cpp +82 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +161 -95
- package/src/duckdb/src/main/capi/value-c.cpp +2 -2
- package/src/duckdb/src/main/chunk_scan_state/batched_data_collection.cpp +57 -0
- package/src/duckdb/src/main/client_config.cpp +17 -0
- package/src/duckdb/src/main/client_context.cpp +67 -52
- package/src/duckdb/src/main/client_data.cpp +3 -3
- package/src/duckdb/src/main/config.cpp +120 -62
- package/src/duckdb/src/main/connection.cpp +14 -2
- package/src/duckdb/src/main/database.cpp +96 -35
- package/src/duckdb/src/main/database_manager.cpp +25 -23
- package/src/duckdb/src/main/database_path_and_type.cpp +2 -2
- package/src/duckdb/src/main/db_instance_cache.cpp +54 -19
- package/src/duckdb/src/main/extension/extension_helper.cpp +47 -42
- package/src/duckdb/src/main/extension/extension_install.cpp +155 -87
- package/src/duckdb/src/main/extension/extension_load.cpp +180 -26
- package/src/duckdb/src/main/extension/extension_util.cpp +8 -0
- package/src/duckdb/src/main/extension.cpp +72 -5
- package/src/duckdb/src/main/pending_query_result.cpp +20 -12
- package/src/duckdb/src/main/prepared_statement.cpp +6 -6
- package/src/duckdb/src/main/prepared_statement_data.cpp +28 -17
- package/src/duckdb/src/main/profiling_info.cpp +196 -0
- package/src/duckdb/src/main/query_profiler.cpp +413 -224
- package/src/duckdb/src/main/query_result.cpp +1 -1
- package/src/duckdb/src/main/relation/create_table_relation.cpp +4 -2
- package/src/duckdb/src/main/relation/create_view_relation.cpp +0 -6
- package/src/duckdb/src/main/relation/delim_get_relation.cpp +44 -0
- package/src/duckdb/src/main/relation/explain_relation.cpp +4 -3
- package/src/duckdb/src/main/relation/join_relation.cpp +5 -0
- package/src/duckdb/src/main/relation/limit_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/materialized_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/query_relation.cpp +42 -15
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +7 -14
- package/src/duckdb/src/main/relation/read_json_relation.cpp +20 -0
- package/src/duckdb/src/main/relation/setop_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/table_function_relation.cpp +6 -0
- package/src/duckdb/src/main/relation/view_relation.cpp +10 -0
- package/src/duckdb/src/main/relation.cpp +12 -8
- package/src/duckdb/src/main/secret/default_secrets.cpp +108 -0
- package/src/duckdb/src/main/secret/secret.cpp +145 -2
- package/src/duckdb/src/main/secret/secret_manager.cpp +85 -35
- package/src/duckdb/src/main/secret/secret_storage.cpp +29 -17
- package/src/duckdb/src/main/settings/settings.cpp +503 -11
- package/src/duckdb/src/main/stream_query_result.cpp +75 -2
- package/src/duckdb/src/optimizer/build_probe_side_optimizer.cpp +248 -0
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +28 -6
- package/src/duckdb/src/optimizer/compressed_materialization/compress_comparison_join.cpp +152 -0
- package/src/duckdb/src/optimizer/compressed_materialization.cpp +11 -1
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +3 -0
- package/src/duckdb/src/optimizer/cte_filter_pusher.cpp +117 -0
- package/src/duckdb/src/optimizer/filter_combiner.cpp +30 -9
- package/src/duckdb/src/optimizer/filter_pullup.cpp +54 -2
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +71 -3
- package/src/duckdb/src/optimizer/join_filter_pushdown_optimizer.cpp +154 -0
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +245 -114
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +42 -20
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +6 -2
- package/src/duckdb/src/optimizer/join_order/plan_enumerator.cpp +32 -10
- package/src/duckdb/src/optimizer/join_order/query_graph_manager.cpp +97 -131
- package/src/duckdb/src/optimizer/join_order/relation_manager.cpp +265 -51
- package/src/duckdb/src/optimizer/join_order/relation_statistics_helper.cpp +21 -17
- package/src/duckdb/src/optimizer/limit_pushdown.cpp +42 -0
- package/src/duckdb/src/optimizer/optimizer.cpp +51 -8
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +17 -17
- package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +22 -4
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +1 -18
- package/src/duckdb/src/optimizer/pushdown/pushdown_inner_join.cpp +6 -0
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +4 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_window.cpp +91 -0
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +21 -25
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +1 -0
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +3 -0
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +8 -2
- package/src/duckdb/src/optimizer/rule/join_dependent_filter.cpp +135 -0
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +1 -1
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +6 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +7 -6
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +1 -1
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +46 -7
- package/src/duckdb/src/parallel/executor.cpp +129 -51
- package/src/duckdb/src/parallel/executor_task.cpp +16 -3
- package/src/duckdb/src/parallel/meta_pipeline.cpp +98 -29
- package/src/duckdb/src/parallel/pipeline.cpp +17 -3
- package/src/duckdb/src/parallel/pipeline_executor.cpp +14 -2
- package/src/duckdb/src/parallel/pipeline_prepare_finish_event.cpp +34 -0
- package/src/duckdb/src/parallel/task_executor.cpp +84 -0
- package/src/duckdb/src/parallel/task_scheduler.cpp +94 -16
- package/src/duckdb/src/parallel/thread_context.cpp +1 -1
- package/src/duckdb/src/parser/expression/function_expression.cpp +14 -0
- package/src/duckdb/src/parser/expression/star_expression.cpp +35 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +5 -1
- package/src/duckdb/src/parser/parsed_data/attach_info.cpp +17 -0
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +37 -28
- package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +44 -2
- package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +21 -1
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +29 -25
- package/src/duckdb/src/parser/parser.cpp +41 -1
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +1 -0
- package/src/duckdb/src/parser/statement/explain_statement.cpp +28 -13
- package/src/duckdb/src/parser/statement/relation_statement.cpp +5 -0
- package/src/duckdb/src/parser/statement/set_statement.cpp +4 -2
- package/src/duckdb/src/parser/statement/transaction_statement.cpp +3 -3
- package/src/duckdb/src/parser/tableref/column_data_ref.cpp +1 -27
- package/src/duckdb/src/parser/tableref/delimgetref.cpp +30 -0
- package/src/duckdb/src/parser/tableref/joinref.cpp +4 -0
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +35 -29
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +32 -32
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +2 -1
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +17 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +5 -0
- package/src/duckdb/src/parser/transform/expression/transform_multi_assign_reference.cpp +36 -34
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +30 -14
- package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_alias.cpp +2 -1
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +27 -19
- package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +31 -28
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +25 -27
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +53 -42
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +6 -6
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_explain.cpp +38 -3
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -2
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_prepare.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_select.cpp +26 -21
- package/src/duckdb/src/parser/transform/statement/transform_set.cpp +8 -8
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +5 -2
- package/src/duckdb/src/parser/transform/statement/transform_show_select.cpp +6 -4
- package/src/duckdb/src/parser/transform/statement/transform_transaction.cpp +27 -6
- package/src/duckdb/src/parser/transform/statement/transform_update.cpp +8 -9
- package/src/duckdb/src/parser/transform/statement/transform_upsert.cpp +11 -12
- package/src/duckdb/src/parser/transform/statement/transform_vacuum.cpp +3 -3
- package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +16 -10
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +1 -1
- package/src/duckdb/src/parser/transformer.cpp +11 -7
- package/src/duckdb/src/planner/bind_context.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +22 -7
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +3 -2
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +11 -4
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +9 -54
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +3 -5
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +24 -27
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_parameter_expression.cpp +9 -2
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +26 -7
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +5 -0
- package/src/duckdb/src/planner/binder/expression/bind_unpacked_star_expression.cpp +91 -0
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +11 -8
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +1 -1
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +6 -10
- package/src/duckdb/src/planner/binder/query_node/plan_cte_node.cpp +14 -10
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +3 -3
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +46 -7
- package/src/duckdb/src/planner/binder/statement/bind_call.cpp +13 -20
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +105 -13
- package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +7 -3
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +75 -55
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +24 -8
- package/src/duckdb/src/planner/binder/statement/bind_explain.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +5 -105
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +109 -41
- package/src/duckdb/src/planner/binder/statement/bind_set.cpp +23 -7
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +4 -1
- package/src/duckdb/src/planner/binder/statement/bind_summarize.cpp +17 -3
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +8 -6
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +55 -42
- package/src/duckdb/src/planner/binder/tableref/bind_column_data_ref.cpp +3 -2
- package/src/duckdb/src/planner/binder/tableref/bind_delimgetref.cpp +16 -0
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +31 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +6 -0
- package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +2 -0
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +106 -46
- package/src/duckdb/src/planner/binder/tableref/plan_delimgetref.cpp +11 -0
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +15 -2
- package/src/duckdb/src/planner/binder/tableref/plan_table_function.cpp +4 -0
- package/src/duckdb/src/planner/binder.cpp +172 -15
- package/src/duckdb/src/planner/collation_binding.cpp +99 -0
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +10 -4
- package/src/duckdb/src/planner/expression/bound_between_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_case_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +14 -12
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_comparison_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_conjunction_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_constant_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_expanded_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +8 -2
- package/src/duckdb/src/planner/expression/bound_lambda_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_lambdaref_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_operator_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_subquery_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_unnest_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +6 -6
- package/src/duckdb/src/planner/expression_binder/aggregate_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/alter_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/column_alias_binder.cpp +7 -0
- package/src/duckdb/src/planner/expression_binder/constant_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +26 -22
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +7 -1
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/insert_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +61 -43
- package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/relation_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/returning_binder.cpp +3 -2
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +10 -3
- package/src/duckdb/src/planner/expression_binder/update_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +9 -2
- package/src/duckdb/src/planner/expression_binder.cpp +121 -21
- package/src/duckdb/src/planner/expression_iterator.cpp +26 -1
- package/src/duckdb/src/planner/filter/conjunction_filter.cpp +33 -0
- package/src/duckdb/src/planner/filter/constant_filter.cpp +15 -0
- package/src/duckdb/src/planner/filter/null_filter.cpp +22 -0
- package/src/duckdb/src/planner/filter/struct_filter.cpp +16 -0
- package/src/duckdb/src/planner/logical_operator.cpp +24 -7
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -7
- package/src/duckdb/src/planner/operator/logical_any_join.cpp +5 -2
- package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +13 -5
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +64 -8
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +7 -0
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +6 -5
- package/src/duckdb/src/planner/operator/logical_get.cpp +60 -18
- package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +7 -0
- package/src/duckdb/src/planner/operator/logical_order.cpp +7 -4
- package/src/duckdb/src/planner/operator/logical_top_n.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_vacuum.cpp +1 -1
- package/src/duckdb/src/planner/planner.cpp +2 -3
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +27 -10
- package/src/duckdb/src/planner/table_filter.cpp +51 -0
- package/src/duckdb/src/storage/arena_allocator.cpp +28 -10
- package/src/duckdb/src/storage/block.cpp +3 -2
- package/src/duckdb/src/storage/buffer/block_handle.cpp +29 -14
- package/src/duckdb/src/storage/buffer/block_manager.cpp +6 -5
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -1
- package/src/duckdb/src/storage/buffer/buffer_pool.cpp +264 -125
- package/src/duckdb/src/storage/buffer_manager.cpp +5 -1
- package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +0 -6
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +26 -3
- package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +21 -9
- package/src/duckdb/src/storage/checkpoint_manager.cpp +49 -24
- package/src/duckdb/src/storage/compression/alp/alp.cpp +6 -11
- package/src/duckdb/src/storage/compression/alprd.cpp +5 -9
- package/src/duckdb/src/storage/compression/bitpacking.cpp +35 -31
- package/src/duckdb/src/storage/compression/chimp/chimp.cpp +6 -8
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +71 -58
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +15 -13
- package/src/duckdb/src/storage/compression/fsst.cpp +66 -53
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +4 -5
- package/src/duckdb/src/storage/compression/patas.cpp +6 -17
- package/src/duckdb/src/storage/compression/rle.cpp +20 -18
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +71 -52
- package/src/duckdb/src/storage/compression/uncompressed.cpp +2 -2
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +8 -7
- package/src/duckdb/src/storage/data_pointer.cpp +22 -0
- package/src/duckdb/src/storage/data_table.cpp +41 -12
- package/src/duckdb/src/storage/local_storage.cpp +22 -8
- package/src/duckdb/src/storage/metadata/metadata_manager.cpp +33 -17
- package/src/duckdb/src/storage/metadata/metadata_reader.cpp +4 -4
- package/src/duckdb/src/storage/metadata/metadata_writer.cpp +3 -3
- package/src/duckdb/src/storage/partial_block_manager.cpp +19 -8
- package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +11 -8
- package/src/duckdb/src/storage/serialization/serialize_expression.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_extension_install_info.cpp +2 -0
- package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +19 -5
- package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +21 -1
- package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +4 -2
- package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +2 -2
- package/src/duckdb/src/storage/serialization/serialize_storage.cpp +2 -0
- package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +8 -4
- package/src/duckdb/src/storage/serialization/serialize_types.cpp +4 -4
- package/src/duckdb/src/storage/single_file_block_manager.cpp +170 -34
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +221 -64
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +4 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +36 -26
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +4 -15
- package/src/duckdb/src/storage/statistics/string_stats.cpp +14 -8
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +2 -1
- package/src/duckdb/src/storage/storage_info.cpp +34 -9
- package/src/duckdb/src/storage/storage_manager.cpp +147 -74
- package/src/duckdb/src/storage/table/array_column_data.cpp +37 -17
- package/src/duckdb/src/storage/table/chunk_info.cpp +38 -0
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +10 -6
- package/src/duckdb/src/storage/table/column_data.cpp +252 -31
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +2 -12
- package/src/duckdb/src/storage/table/column_segment.cpp +63 -34
- package/src/duckdb/src/storage/table/list_column_data.cpp +34 -15
- package/src/duckdb/src/storage/table/row_group.cpp +228 -120
- package/src/duckdb/src/storage/table/row_group_collection.cpp +122 -120
- package/src/duckdb/src/storage/table/row_version_manager.cpp +27 -1
- package/src/duckdb/src/storage/table/scan_state.cpp +101 -18
- package/src/duckdb/src/storage/table/standard_column_data.cpp +20 -34
- package/src/duckdb/src/storage/table/struct_column_data.cpp +39 -42
- package/src/duckdb/src/storage/table/table_statistics.cpp +2 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +9 -8
- package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -2
- package/src/duckdb/src/storage/table_index_list.cpp +8 -7
- package/src/duckdb/src/storage/temporary_file_manager.cpp +11 -9
- package/src/duckdb/src/storage/temporary_memory_manager.cpp +227 -39
- package/src/duckdb/src/storage/wal_replay.cpp +68 -28
- package/src/duckdb/src/storage/write_ahead_log.cpp +56 -47
- package/src/duckdb/src/transaction/cleanup_state.cpp +9 -1
- package/src/duckdb/src/transaction/commit_state.cpp +7 -170
- package/src/duckdb/src/transaction/duck_transaction.cpp +87 -19
- package/src/duckdb/src/transaction/duck_transaction_manager.cpp +65 -10
- package/src/duckdb/src/transaction/meta_transaction.cpp +18 -3
- package/src/duckdb/src/transaction/transaction_context.cpp +21 -17
- package/src/duckdb/src/transaction/undo_buffer.cpp +20 -14
- package/src/duckdb/src/transaction/wal_write_state.cpp +292 -0
- package/src/duckdb/src/verification/prepared_statement_verifier.cpp +0 -1
- package/src/duckdb/third_party/brotli/common/brotli_constants.h +204 -0
- package/src/duckdb/third_party/brotli/common/brotli_platform.h +543 -0
- package/src/duckdb/third_party/brotli/common/constants.cpp +17 -0
- package/src/duckdb/third_party/brotli/common/context.cpp +156 -0
- package/src/duckdb/third_party/brotli/common/context.h +110 -0
- package/src/duckdb/third_party/brotli/common/dictionary.cpp +5912 -0
- package/src/duckdb/third_party/brotli/common/dictionary.h +60 -0
- package/src/duckdb/third_party/brotli/common/platform.cpp +24 -0
- package/src/duckdb/third_party/brotli/common/shared_dictionary.cpp +517 -0
- package/src/duckdb/third_party/brotli/common/shared_dictionary_internal.h +71 -0
- package/src/duckdb/third_party/brotli/common/transform.cpp +287 -0
- package/src/duckdb/third_party/brotli/common/transform.h +77 -0
- package/src/duckdb/third_party/brotli/common/version.h +51 -0
- package/src/duckdb/third_party/brotli/dec/bit_reader.cpp +74 -0
- package/src/duckdb/third_party/brotli/dec/bit_reader.h +419 -0
- package/src/duckdb/third_party/brotli/dec/decode.cpp +2758 -0
- package/src/duckdb/third_party/brotli/dec/huffman.cpp +338 -0
- package/src/duckdb/third_party/brotli/dec/huffman.h +118 -0
- package/src/duckdb/third_party/brotli/dec/prefix.h +733 -0
- package/src/duckdb/third_party/brotli/dec/state.cpp +178 -0
- package/src/duckdb/third_party/brotli/dec/state.h +386 -0
- package/src/duckdb/third_party/brotli/enc/backward_references.cpp +3775 -0
- package/src/duckdb/third_party/brotli/enc/backward_references.h +36 -0
- package/src/duckdb/third_party/brotli/enc/backward_references_hq.cpp +935 -0
- package/src/duckdb/third_party/brotli/enc/backward_references_hq.h +92 -0
- package/src/duckdb/third_party/brotli/enc/bit_cost.cpp +410 -0
- package/src/duckdb/third_party/brotli/enc/bit_cost.h +60 -0
- package/src/duckdb/third_party/brotli/enc/block_splitter.cpp +1653 -0
- package/src/duckdb/third_party/brotli/enc/block_splitter.h +48 -0
- package/src/duckdb/third_party/brotli/enc/brotli_bit_stream.cpp +1431 -0
- package/src/duckdb/third_party/brotli/enc/brotli_bit_stream.h +85 -0
- package/src/duckdb/third_party/brotli/enc/brotli_hash.h +4352 -0
- package/src/duckdb/third_party/brotli/enc/brotli_params.h +47 -0
- package/src/duckdb/third_party/brotli/enc/cluster.cpp +1025 -0
- package/src/duckdb/third_party/brotli/enc/cluster.h +1017 -0
- package/src/duckdb/third_party/brotli/enc/command.cpp +24 -0
- package/src/duckdb/third_party/brotli/enc/command.h +187 -0
- package/src/duckdb/third_party/brotli/enc/compound_dictionary.cpp +209 -0
- package/src/duckdb/third_party/brotli/enc/compound_dictionary.h +75 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment.cpp +796 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment.h +82 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment_two_pass.cpp +653 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment_two_pass.h +68 -0
- package/src/duckdb/third_party/brotli/enc/dictionary_hash.cpp +1844 -0
- package/src/duckdb/third_party/brotli/enc/dictionary_hash.h +21 -0
- package/src/duckdb/third_party/brotli/enc/encode.cpp +1990 -0
- package/src/duckdb/third_party/brotli/enc/encoder_dict.cpp +636 -0
- package/src/duckdb/third_party/brotli/enc/encoder_dict.h +153 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode.cpp +500 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode.h +119 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode_static.h +538 -0
- package/src/duckdb/third_party/brotli/enc/fast_log.cpp +101 -0
- package/src/duckdb/third_party/brotli/enc/fast_log.h +63 -0
- package/src/duckdb/third_party/brotli/enc/find_match_length.h +68 -0
- package/src/duckdb/third_party/brotli/enc/histogram.cpp +96 -0
- package/src/duckdb/third_party/brotli/enc/histogram.h +210 -0
- package/src/duckdb/third_party/brotli/enc/literal_cost.cpp +176 -0
- package/src/duckdb/third_party/brotli/enc/literal_cost.h +28 -0
- package/src/duckdb/third_party/brotli/enc/memory.cpp +190 -0
- package/src/duckdb/third_party/brotli/enc/memory.h +127 -0
- package/src/duckdb/third_party/brotli/enc/metablock.cpp +1225 -0
- package/src/duckdb/third_party/brotli/enc/metablock.h +102 -0
- package/src/duckdb/third_party/brotli/enc/prefix.h +50 -0
- package/src/duckdb/third_party/brotli/enc/quality.h +202 -0
- package/src/duckdb/third_party/brotli/enc/ringbuffer.h +164 -0
- package/src/duckdb/third_party/brotli/enc/state.h +106 -0
- package/src/duckdb/third_party/brotli/enc/static_dict.cpp +538 -0
- package/src/duckdb/third_party/brotli/enc/static_dict.h +37 -0
- package/src/duckdb/third_party/brotli/enc/static_dict_lut.h +5862 -0
- package/src/duckdb/third_party/brotli/enc/utf8_util.cpp +81 -0
- package/src/duckdb/third_party/brotli/enc/utf8_util.h +29 -0
- package/src/duckdb/third_party/brotli/enc/write_bits.h +84 -0
- package/src/duckdb/third_party/brotli/include/brotli/decode.h +405 -0
- package/src/duckdb/third_party/brotli/include/brotli/encode.h +489 -0
- package/src/duckdb/third_party/brotli/include/brotli/port.h +238 -0
- package/src/duckdb/third_party/brotli/include/brotli/shared_dictionary.h +96 -0
- package/src/duckdb/third_party/brotli/include/brotli/types.h +83 -0
- package/src/duckdb/third_party/fast_float/fast_float/fast_float.h +20 -4
- package/src/duckdb/third_party/fmt/include/fmt/format.h +54 -10
- package/src/duckdb/third_party/fsst/fsst.h +2 -2
- package/src/duckdb/third_party/fsst/libfsst.hpp +2 -2
- package/src/duckdb/third_party/httplib/httplib.hpp +6763 -5580
- package/src/duckdb/third_party/hyperloglog/hyperloglog.cpp +13 -30
- package/src/duckdb/third_party/hyperloglog/hyperloglog.hpp +8 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +22 -9
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1041 -554
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/postgres_parser.cpp +2 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +21605 -21752
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +538 -299
- package/src/duckdb/third_party/mbedtls/include/mbedtls/mbedtls_config.h +1 -0
- package/src/duckdb/third_party/mbedtls/include/mbedtls_wrapper.hpp +36 -12
- package/src/duckdb/third_party/mbedtls/library/md.cpp +6 -6
- package/src/duckdb/third_party/mbedtls/library/sha1.cpp +2 -0
- package/src/duckdb/third_party/mbedtls/library/sha256.cpp +3 -0
- package/src/duckdb/third_party/mbedtls/mbedtls_wrapper.cpp +99 -47
- package/src/duckdb/third_party/pcg/pcg_extras.hpp +1 -1
- package/src/duckdb/third_party/re2/re2/prog.cc +2 -2
- package/src/duckdb/third_party/snappy/snappy-internal.h +398 -0
- package/src/duckdb/third_party/snappy/snappy-sinksource.cc +111 -9
- package/src/duckdb/third_party/snappy/snappy-sinksource.h +158 -0
- package/src/duckdb/third_party/snappy/snappy-stubs-internal.h +523 -3
- package/src/duckdb/third_party/snappy/snappy-stubs-public.h +34 -1
- package/src/duckdb/third_party/snappy/snappy.cc +2626 -0
- package/src/duckdb/third_party/snappy/snappy.h +223 -0
- package/src/duckdb/third_party/snappy/snappy_version.hpp +11 -0
- package/src/duckdb/third_party/utf8proc/include/utf8proc.hpp +69 -101
- package/src/duckdb/third_party/utf8proc/include/utf8proc_wrapper.hpp +53 -0
- package/src/duckdb/third_party/utf8proc/utf8proc.cpp +627 -678
- package/src/duckdb/third_party/utf8proc/utf8proc_data.cpp +15008 -12868
- package/src/duckdb/third_party/utf8proc/utf8proc_wrapper.cpp +185 -29
- package/src/duckdb/ub_extension_json_json_functions.cpp +6 -0
- package/src/duckdb/ub_src_catalog_default.cpp +4 -0
- package/src/duckdb/ub_src_common.cpp +7 -1
- package/src/duckdb/ub_src_common_arrow.cpp +10 -0
- package/src/duckdb/ub_src_common_enums.cpp +2 -0
- package/src/duckdb/ub_src_common_tree_renderer.cpp +10 -0
- package/src/duckdb/ub_src_common_types.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_aggregate_holistic.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_aggregate_nested.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_generic.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_list.cpp +2 -4
- package/src/duckdb/ub_src_core_functions_scalar_map.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +4 -0
- package/src/duckdb/ub_src_execution_index_art.cpp +5 -3
- package/src/duckdb/ub_src_execution_operator_csv_scanner_scanner.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_helper.cpp +4 -0
- package/src/duckdb/ub_src_function.cpp +4 -0
- package/src/duckdb/ub_src_function_cast.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_generic.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_list.cpp +0 -2
- package/src/duckdb/ub_src_function_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_function_table.cpp +2 -0
- package/src/duckdb/ub_src_function_table_arrow.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
- package/src/duckdb/ub_src_main.cpp +4 -0
- package/src/duckdb/ub_src_main_buffered_data.cpp +4 -0
- package/src/duckdb/ub_src_main_capi.cpp +10 -0
- package/src/duckdb/ub_src_main_chunk_scan_state.cpp +2 -0
- package/src/duckdb/ub_src_main_relation.cpp +2 -0
- package/src/duckdb/ub_src_main_secret.cpp +2 -0
- package/src/duckdb/ub_src_optimizer.cpp +8 -0
- package/src/duckdb/ub_src_optimizer_compressed_materialization.cpp +2 -0
- package/src/duckdb/ub_src_optimizer_pushdown.cpp +2 -0
- package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
- package/src/duckdb/ub_src_parallel.cpp +4 -0
- package/src/duckdb/ub_src_parser_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +4 -0
- package/src/duckdb/ub_src_storage_statistics.cpp +0 -2
- package/src/duckdb/ub_src_transaction.cpp +2 -0
- package/test/columns.test.ts +1 -1
- package/test/prepare.test.ts +1 -1
- package/test/test_all_types.test.ts +1 -1
@@ -0,0 +1,935 @@
|
|
1
|
+
/* Copyright 2013 Google Inc. All Rights Reserved.
|
2
|
+
|
3
|
+
Distributed under MIT license.
|
4
|
+
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
/* Function to find backward reference copies. */
|
8
|
+
|
9
|
+
#include "backward_references_hq.h"
|
10
|
+
|
11
|
+
#include <string.h> /* memcpy, memset */
|
12
|
+
|
13
|
+
#include <brotli/types.h>
|
14
|
+
|
15
|
+
#include "../common/brotli_constants.h"
|
16
|
+
#include "../common/brotli_platform.h"
|
17
|
+
#include "command.h"
|
18
|
+
#include "compound_dictionary.h"
|
19
|
+
#include "encoder_dict.h"
|
20
|
+
#include "fast_log.h"
|
21
|
+
#include "find_match_length.h"
|
22
|
+
#include "literal_cost.h"
|
23
|
+
#include "memory.h"
|
24
|
+
#include "brotli_params.h"
|
25
|
+
#include "prefix.h"
|
26
|
+
#include "quality.h"
|
27
|
+
|
28
|
+
using namespace duckdb_brotli;
|
29
|
+
|
30
|
+
/* BrotliCalculateDistanceCodeLimit(BROTLI_MAX_ALLOWED_DISTANCE, 3, 120). */
|
31
|
+
#define BROTLI_MAX_EFFECTIVE_DISTANCE_ALPHABET_SIZE 544
|
32
|
+
|
33
|
+
static const float kInfinity = 1.7e38f; /* ~= 2 ^ 127 */
|
34
|
+
|
35
|
+
static const uint32_t kDistanceCacheIndex[] = {
|
36
|
+
0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
|
37
|
+
};
|
38
|
+
static const int kDistanceCacheOffset[] = {
|
39
|
+
0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3
|
40
|
+
};
|
41
|
+
|
42
|
+
void duckdb_brotli::BrotliInitZopfliNodes(ZopfliNode* array, size_t length) {
|
43
|
+
ZopfliNode stub;
|
44
|
+
size_t i;
|
45
|
+
stub.length = 1;
|
46
|
+
stub.distance = 0;
|
47
|
+
stub.dcode_insert_length = 0;
|
48
|
+
stub.u.cost = kInfinity;
|
49
|
+
for (i = 0; i < length; ++i) array[i] = stub;
|
50
|
+
}
|
51
|
+
|
52
|
+
static BROTLI_INLINE uint32_t ZopfliNodeCopyLength(const ZopfliNode* self) {
|
53
|
+
return self->length & 0x1FFFFFF;
|
54
|
+
}
|
55
|
+
|
56
|
+
static BROTLI_INLINE uint32_t ZopfliNodeLengthCode(const ZopfliNode* self) {
|
57
|
+
const uint32_t modifier = self->length >> 25;
|
58
|
+
return ZopfliNodeCopyLength(self) + 9u - modifier;
|
59
|
+
}
|
60
|
+
|
61
|
+
static BROTLI_INLINE uint32_t ZopfliNodeCopyDistance(const ZopfliNode* self) {
|
62
|
+
return self->distance;
|
63
|
+
}
|
64
|
+
|
65
|
+
static BROTLI_INLINE uint32_t ZopfliNodeDistanceCode(const ZopfliNode* self) {
|
66
|
+
const uint32_t short_code = self->dcode_insert_length >> 27;
|
67
|
+
return short_code == 0 ?
|
68
|
+
ZopfliNodeCopyDistance(self) + BROTLI_NUM_DISTANCE_SHORT_CODES - 1 :
|
69
|
+
short_code - 1;
|
70
|
+
}
|
71
|
+
|
72
|
+
static BROTLI_INLINE uint32_t ZopfliNodeCommandLength(const ZopfliNode* self) {
|
73
|
+
return ZopfliNodeCopyLength(self) + (self->dcode_insert_length & 0x7FFFFFF);
|
74
|
+
}
|
75
|
+
|
76
|
+
/* Temporary data for ZopfliCostModelSetFromCommands. */
|
77
|
+
typedef struct ZopfliCostModelArena {
|
78
|
+
uint32_t histogram_literal[BROTLI_NUM_LITERAL_SYMBOLS];
|
79
|
+
uint32_t histogram_cmd[BROTLI_NUM_COMMAND_SYMBOLS];
|
80
|
+
uint32_t histogram_dist[BROTLI_MAX_EFFECTIVE_DISTANCE_ALPHABET_SIZE];
|
81
|
+
float cost_literal[BROTLI_NUM_LITERAL_SYMBOLS];
|
82
|
+
} ZopfliCostModelArena;
|
83
|
+
|
84
|
+
/* Histogram based cost model for zopflification. */
|
85
|
+
typedef struct ZopfliCostModel {
|
86
|
+
/* The insert and copy length symbols. */
|
87
|
+
float cost_cmd_[BROTLI_NUM_COMMAND_SYMBOLS];
|
88
|
+
float* cost_dist_;
|
89
|
+
uint32_t distance_histogram_size;
|
90
|
+
/* Cumulative costs of literals per position in the stream. */
|
91
|
+
float* literal_costs_;
|
92
|
+
float min_cost_cmd_;
|
93
|
+
size_t num_bytes_;
|
94
|
+
|
95
|
+
/* Temporary data. */
|
96
|
+
union {
|
97
|
+
size_t literal_histograms[3 * 256];
|
98
|
+
ZopfliCostModelArena arena;
|
99
|
+
};
|
100
|
+
} ZopfliCostModel;
|
101
|
+
|
102
|
+
static void InitZopfliCostModel(
|
103
|
+
MemoryManager* m, ZopfliCostModel* self, const BrotliDistanceParams* dist,
|
104
|
+
size_t num_bytes) {
|
105
|
+
self->num_bytes_ = num_bytes;
|
106
|
+
self->literal_costs_ = BROTLI_ALLOC(m, float, num_bytes + 2);
|
107
|
+
self->cost_dist_ = BROTLI_ALLOC(m, float, dist->alphabet_size_limit);
|
108
|
+
self->distance_histogram_size = dist->alphabet_size_limit;
|
109
|
+
if (BROTLI_IS_OOM(m)) return;
|
110
|
+
}
|
111
|
+
|
112
|
+
static void CleanupZopfliCostModel(MemoryManager* m, ZopfliCostModel* self) {
|
113
|
+
BROTLI_FREE(m, self->literal_costs_);
|
114
|
+
BROTLI_FREE(m, self->cost_dist_);
|
115
|
+
}
|
116
|
+
|
117
|
+
static void SetCost(const uint32_t* histogram, size_t histogram_size,
|
118
|
+
BROTLI_BOOL literal_histogram, float* cost) {
|
119
|
+
size_t sum = 0;
|
120
|
+
size_t missing_symbol_sum;
|
121
|
+
float log2sum;
|
122
|
+
float missing_symbol_cost;
|
123
|
+
size_t i;
|
124
|
+
for (i = 0; i < histogram_size; i++) {
|
125
|
+
sum += histogram[i];
|
126
|
+
}
|
127
|
+
log2sum = (float)FastLog2(sum);
|
128
|
+
missing_symbol_sum = sum;
|
129
|
+
if (!literal_histogram) {
|
130
|
+
for (i = 0; i < histogram_size; i++) {
|
131
|
+
if (histogram[i] == 0) missing_symbol_sum++;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
missing_symbol_cost = (float)FastLog2(missing_symbol_sum) + 2;
|
135
|
+
for (i = 0; i < histogram_size; i++) {
|
136
|
+
if (histogram[i] == 0) {
|
137
|
+
cost[i] = missing_symbol_cost;
|
138
|
+
continue;
|
139
|
+
}
|
140
|
+
|
141
|
+
/* Shannon bits for this symbol. */
|
142
|
+
cost[i] = log2sum - (float)FastLog2(histogram[i]);
|
143
|
+
|
144
|
+
/* Cannot be coded with less than 1 bit */
|
145
|
+
if (cost[i] < 1) cost[i] = 1;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
static void ZopfliCostModelSetFromCommands(ZopfliCostModel* self,
|
150
|
+
size_t position,
|
151
|
+
const uint8_t* ringbuffer,
|
152
|
+
size_t ringbuffer_mask,
|
153
|
+
const Command* commands,
|
154
|
+
size_t num_commands,
|
155
|
+
size_t last_insert_len) {
|
156
|
+
ZopfliCostModelArena* arena = &self->arena;
|
157
|
+
size_t pos = position - last_insert_len;
|
158
|
+
float min_cost_cmd = kInfinity;
|
159
|
+
size_t i;
|
160
|
+
float* cost_cmd = self->cost_cmd_;
|
161
|
+
|
162
|
+
memset(arena->histogram_literal, 0, sizeof(arena->histogram_literal));
|
163
|
+
memset(arena->histogram_cmd, 0, sizeof(arena->histogram_cmd));
|
164
|
+
memset(arena->histogram_dist, 0, sizeof(arena->histogram_dist));
|
165
|
+
|
166
|
+
for (i = 0; i < num_commands; i++) {
|
167
|
+
size_t inslength = commands[i].insert_len_;
|
168
|
+
size_t copylength = CommandCopyLen(&commands[i]);
|
169
|
+
size_t distcode = commands[i].dist_prefix_ & 0x3FF;
|
170
|
+
size_t cmdcode = commands[i].cmd_prefix_;
|
171
|
+
size_t j;
|
172
|
+
|
173
|
+
arena->histogram_cmd[cmdcode]++;
|
174
|
+
if (cmdcode >= 128) arena->histogram_dist[distcode]++;
|
175
|
+
|
176
|
+
for (j = 0; j < inslength; j++) {
|
177
|
+
arena->histogram_literal[ringbuffer[(pos + j) & ringbuffer_mask]]++;
|
178
|
+
}
|
179
|
+
|
180
|
+
pos += inslength + copylength;
|
181
|
+
}
|
182
|
+
|
183
|
+
SetCost(arena->histogram_literal, BROTLI_NUM_LITERAL_SYMBOLS, BROTLI_TRUE,
|
184
|
+
arena->cost_literal);
|
185
|
+
SetCost(arena->histogram_cmd, BROTLI_NUM_COMMAND_SYMBOLS, BROTLI_FALSE,
|
186
|
+
cost_cmd);
|
187
|
+
SetCost(arena->histogram_dist, self->distance_histogram_size, BROTLI_FALSE,
|
188
|
+
self->cost_dist_);
|
189
|
+
|
190
|
+
for (i = 0; i < BROTLI_NUM_COMMAND_SYMBOLS; ++i) {
|
191
|
+
min_cost_cmd = BROTLI_MIN(float, min_cost_cmd, cost_cmd[i]);
|
192
|
+
}
|
193
|
+
self->min_cost_cmd_ = min_cost_cmd;
|
194
|
+
|
195
|
+
{
|
196
|
+
float* literal_costs = self->literal_costs_;
|
197
|
+
float literal_carry = 0.0;
|
198
|
+
size_t num_bytes = self->num_bytes_;
|
199
|
+
literal_costs[0] = 0.0;
|
200
|
+
for (i = 0; i < num_bytes; ++i) {
|
201
|
+
literal_carry +=
|
202
|
+
arena->cost_literal[ringbuffer[(position + i) & ringbuffer_mask]];
|
203
|
+
literal_costs[i + 1] = literal_costs[i] + literal_carry;
|
204
|
+
literal_carry -= literal_costs[i + 1] - literal_costs[i];
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
static void ZopfliCostModelSetFromLiteralCosts(ZopfliCostModel* self,
|
210
|
+
size_t position,
|
211
|
+
const uint8_t* ringbuffer,
|
212
|
+
size_t ringbuffer_mask) {
|
213
|
+
float* literal_costs = self->literal_costs_;
|
214
|
+
float literal_carry = 0.0;
|
215
|
+
float* cost_dist = self->cost_dist_;
|
216
|
+
float* cost_cmd = self->cost_cmd_;
|
217
|
+
size_t num_bytes = self->num_bytes_;
|
218
|
+
size_t i;
|
219
|
+
BrotliEstimateBitCostsForLiterals(position, num_bytes, ringbuffer_mask,
|
220
|
+
ringbuffer, self->literal_histograms,
|
221
|
+
&literal_costs[1]);
|
222
|
+
literal_costs[0] = 0.0;
|
223
|
+
for (i = 0; i < num_bytes; ++i) {
|
224
|
+
literal_carry += literal_costs[i + 1];
|
225
|
+
literal_costs[i + 1] = literal_costs[i] + literal_carry;
|
226
|
+
literal_carry -= literal_costs[i + 1] - literal_costs[i];
|
227
|
+
}
|
228
|
+
for (i = 0; i < BROTLI_NUM_COMMAND_SYMBOLS; ++i) {
|
229
|
+
cost_cmd[i] = (float)FastLog2(11 + (uint32_t)i);
|
230
|
+
}
|
231
|
+
for (i = 0; i < self->distance_histogram_size; ++i) {
|
232
|
+
cost_dist[i] = (float)FastLog2(20 + (uint32_t)i);
|
233
|
+
}
|
234
|
+
self->min_cost_cmd_ = (float)FastLog2(11);
|
235
|
+
}
|
236
|
+
|
237
|
+
static BROTLI_INLINE float ZopfliCostModelGetCommandCost(
|
238
|
+
const ZopfliCostModel* self, uint16_t cmdcode) {
|
239
|
+
return self->cost_cmd_[cmdcode];
|
240
|
+
}
|
241
|
+
|
242
|
+
static BROTLI_INLINE float ZopfliCostModelGetDistanceCost(
|
243
|
+
const ZopfliCostModel* self, size_t distcode) {
|
244
|
+
return self->cost_dist_[distcode];
|
245
|
+
}
|
246
|
+
|
247
|
+
static BROTLI_INLINE float ZopfliCostModelGetLiteralCosts(
|
248
|
+
const ZopfliCostModel* self, size_t from, size_t to) {
|
249
|
+
return self->literal_costs_[to] - self->literal_costs_[from];
|
250
|
+
}
|
251
|
+
|
252
|
+
static BROTLI_INLINE float ZopfliCostModelGetMinCostCmd(
|
253
|
+
const ZopfliCostModel* self) {
|
254
|
+
return self->min_cost_cmd_;
|
255
|
+
}
|
256
|
+
|
257
|
+
/* REQUIRES: len >= 2, start_pos <= pos */
|
258
|
+
/* REQUIRES: cost < kInfinity, nodes[start_pos].cost < kInfinity */
|
259
|
+
/* Maintains the "ZopfliNode array invariant". */
|
260
|
+
static BROTLI_INLINE void UpdateZopfliNode(ZopfliNode* nodes, size_t pos,
|
261
|
+
size_t start_pos, size_t len, size_t len_code, size_t dist,
|
262
|
+
size_t short_code, float cost) {
|
263
|
+
ZopfliNode* next = &nodes[pos + len];
|
264
|
+
next->length = (uint32_t)(len | ((len + 9u - len_code) << 25));
|
265
|
+
next->distance = (uint32_t)dist;
|
266
|
+
next->dcode_insert_length = (uint32_t)(
|
267
|
+
(short_code << 27) | (pos - start_pos));
|
268
|
+
next->u.cost = cost;
|
269
|
+
}
|
270
|
+
|
271
|
+
typedef struct PosData {
|
272
|
+
size_t pos;
|
273
|
+
int distance_cache[4];
|
274
|
+
float costdiff;
|
275
|
+
float cost;
|
276
|
+
} PosData;
|
277
|
+
|
278
|
+
/* Maintains the smallest 8 cost difference together with their positions */
|
279
|
+
typedef struct StartPosQueue {
|
280
|
+
PosData q_[8];
|
281
|
+
size_t idx_;
|
282
|
+
} StartPosQueue;
|
283
|
+
|
284
|
+
static BROTLI_INLINE void InitStartPosQueue(StartPosQueue* self) {
|
285
|
+
self->idx_ = 0;
|
286
|
+
}
|
287
|
+
|
288
|
+
static size_t StartPosQueueSize(const StartPosQueue* self) {
|
289
|
+
return BROTLI_MIN(size_t, self->idx_, 8);
|
290
|
+
}
|
291
|
+
|
292
|
+
static void StartPosQueuePush(StartPosQueue* self, const PosData* posdata) {
|
293
|
+
size_t offset = ~(self->idx_++) & 7;
|
294
|
+
size_t len = StartPosQueueSize(self);
|
295
|
+
size_t i;
|
296
|
+
PosData* q = self->q_;
|
297
|
+
q[offset] = *posdata;
|
298
|
+
/* Restore the sorted order. In the list of |len| items at most |len - 1|
|
299
|
+
adjacent element comparisons / swaps are required. */
|
300
|
+
for (i = 1; i < len; ++i) {
|
301
|
+
if (q[offset & 7].costdiff > q[(offset + 1) & 7].costdiff) {
|
302
|
+
BROTLI_SWAP(PosData, q, offset & 7, (offset + 1) & 7);
|
303
|
+
}
|
304
|
+
++offset;
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
static const PosData* StartPosQueueAt(const StartPosQueue* self, size_t k) {
|
309
|
+
return &self->q_[(k - self->idx_) & 7];
|
310
|
+
}
|
311
|
+
|
312
|
+
/* Returns the minimum possible copy length that can improve the cost of any */
|
313
|
+
/* future position. */
|
314
|
+
static size_t ComputeMinimumCopyLength(const float start_cost,
|
315
|
+
const ZopfliNode* nodes,
|
316
|
+
const size_t num_bytes,
|
317
|
+
const size_t pos) {
|
318
|
+
/* Compute the minimum possible cost of reaching any future position. */
|
319
|
+
float min_cost = start_cost;
|
320
|
+
size_t len = 2;
|
321
|
+
size_t next_len_bucket = 4;
|
322
|
+
size_t next_len_offset = 10;
|
323
|
+
while (pos + len <= num_bytes && nodes[pos + len].u.cost <= min_cost) {
|
324
|
+
/* We already reached (pos + len) with no more cost than the minimum
|
325
|
+
possible cost of reaching anything from this pos, so there is no point in
|
326
|
+
looking for lengths <= len. */
|
327
|
+
++len;
|
328
|
+
if (len == next_len_offset) {
|
329
|
+
/* We reached the next copy length code bucket, so we add one more
|
330
|
+
extra bit to the minimum cost. */
|
331
|
+
min_cost += 1.0f;
|
332
|
+
next_len_offset += next_len_bucket;
|
333
|
+
next_len_bucket *= 2;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
return len;
|
337
|
+
}
|
338
|
+
|
339
|
+
/* REQUIRES: nodes[pos].cost < kInfinity
|
340
|
+
REQUIRES: nodes[0..pos] satisfies that "ZopfliNode array invariant". */
|
341
|
+
static uint32_t ComputeDistanceShortcut(const size_t block_start,
|
342
|
+
const size_t pos,
|
343
|
+
const size_t max_backward_limit,
|
344
|
+
const size_t gap,
|
345
|
+
const ZopfliNode* nodes) {
|
346
|
+
const size_t clen = ZopfliNodeCopyLength(&nodes[pos]);
|
347
|
+
const size_t ilen = nodes[pos].dcode_insert_length & 0x7FFFFFF;
|
348
|
+
const size_t dist = ZopfliNodeCopyDistance(&nodes[pos]);
|
349
|
+
/* Since |block_start + pos| is the end position of the command, the copy part
|
350
|
+
starts from |block_start + pos - clen|. Distances that are greater than
|
351
|
+
this or greater than |max_backward_limit| + |gap| are static dictionary
|
352
|
+
references, and do not update the last distances.
|
353
|
+
Also distance code 0 (last distance) does not update the last distances. */
|
354
|
+
if (pos == 0) {
|
355
|
+
return 0;
|
356
|
+
} else if (dist + clen <= block_start + pos + gap &&
|
357
|
+
dist <= max_backward_limit + gap &&
|
358
|
+
ZopfliNodeDistanceCode(&nodes[pos]) > 0) {
|
359
|
+
return (uint32_t)pos;
|
360
|
+
} else {
|
361
|
+
return nodes[pos - clen - ilen].u.shortcut;
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
/* Fills in dist_cache[0..3] with the last four distances (as defined by
|
366
|
+
Section 4. of the Spec) that would be used at (block_start + pos) if we
|
367
|
+
used the shortest path of commands from block_start, computed from
|
368
|
+
nodes[0..pos]. The last four distances at block_start are in
|
369
|
+
starting_dist_cache[0..3].
|
370
|
+
REQUIRES: nodes[pos].cost < kInfinity
|
371
|
+
REQUIRES: nodes[0..pos] satisfies that "ZopfliNode array invariant". */
|
372
|
+
static void ComputeDistanceCache(const size_t pos,
|
373
|
+
const int* starting_dist_cache,
|
374
|
+
const ZopfliNode* nodes,
|
375
|
+
int* dist_cache) {
|
376
|
+
int idx = 0;
|
377
|
+
size_t p = nodes[pos].u.shortcut;
|
378
|
+
while (idx < 4 && p > 0) {
|
379
|
+
const size_t ilen = nodes[p].dcode_insert_length & 0x7FFFFFF;
|
380
|
+
const size_t clen = ZopfliNodeCopyLength(&nodes[p]);
|
381
|
+
const size_t dist = ZopfliNodeCopyDistance(&nodes[p]);
|
382
|
+
dist_cache[idx++] = (int)dist;
|
383
|
+
/* Because of prerequisite, p >= clen + ilen >= 2. */
|
384
|
+
p = nodes[p - clen - ilen].u.shortcut;
|
385
|
+
}
|
386
|
+
for (; idx < 4; ++idx) {
|
387
|
+
dist_cache[idx] = *starting_dist_cache++;
|
388
|
+
}
|
389
|
+
}
|
390
|
+
|
391
|
+
/* Maintains "ZopfliNode array invariant" and pushes node to the queue, if it
|
392
|
+
is eligible. */
|
393
|
+
static void EvaluateNode(
|
394
|
+
const size_t block_start, const size_t pos, const size_t max_backward_limit,
|
395
|
+
const size_t gap, const int* starting_dist_cache,
|
396
|
+
const ZopfliCostModel* model, StartPosQueue* queue, ZopfliNode* nodes) {
|
397
|
+
/* Save cost, because ComputeDistanceCache invalidates it. */
|
398
|
+
float node_cost = nodes[pos].u.cost;
|
399
|
+
nodes[pos].u.shortcut = ComputeDistanceShortcut(
|
400
|
+
block_start, pos, max_backward_limit, gap, nodes);
|
401
|
+
if (node_cost <= ZopfliCostModelGetLiteralCosts(model, 0, pos)) {
|
402
|
+
PosData posdata;
|
403
|
+
posdata.pos = pos;
|
404
|
+
posdata.cost = node_cost;
|
405
|
+
posdata.costdiff = node_cost -
|
406
|
+
ZopfliCostModelGetLiteralCosts(model, 0, pos);
|
407
|
+
ComputeDistanceCache(
|
408
|
+
pos, starting_dist_cache, nodes, posdata.distance_cache);
|
409
|
+
StartPosQueuePush(queue, &posdata);
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
/* Returns longest copy length. */
|
414
|
+
static size_t UpdateNodes(
|
415
|
+
const size_t num_bytes, const size_t block_start, const size_t pos,
|
416
|
+
const uint8_t* ringbuffer, const size_t ringbuffer_mask,
|
417
|
+
const BrotliEncoderParams* params, const size_t max_backward_limit,
|
418
|
+
const int* starting_dist_cache, const size_t num_matches,
|
419
|
+
const BackwardMatch* matches, const ZopfliCostModel* model,
|
420
|
+
StartPosQueue* queue, ZopfliNode* nodes) {
|
421
|
+
const size_t stream_offset = params->stream_offset;
|
422
|
+
const size_t cur_ix = block_start + pos;
|
423
|
+
const size_t cur_ix_masked = cur_ix & ringbuffer_mask;
|
424
|
+
const size_t max_distance = BROTLI_MIN(size_t, cur_ix, max_backward_limit);
|
425
|
+
const size_t dictionary_start = BROTLI_MIN(size_t,
|
426
|
+
cur_ix + stream_offset, max_backward_limit);
|
427
|
+
const size_t max_len = num_bytes - pos;
|
428
|
+
const size_t max_zopfli_len = MaxZopfliLen(params);
|
429
|
+
const size_t max_iters = MaxZopfliCandidates(params);
|
430
|
+
size_t min_len;
|
431
|
+
size_t result = 0;
|
432
|
+
size_t k;
|
433
|
+
const CompoundDictionary* addon = ¶ms->dictionary.compound;
|
434
|
+
size_t gap = addon->total_size;
|
435
|
+
|
436
|
+
EvaluateNode(block_start + stream_offset, pos, max_backward_limit, gap,
|
437
|
+
starting_dist_cache, model, queue, nodes);
|
438
|
+
|
439
|
+
{
|
440
|
+
const PosData* posdata = StartPosQueueAt(queue, 0);
|
441
|
+
float min_cost = (posdata->cost + ZopfliCostModelGetMinCostCmd(model) +
|
442
|
+
ZopfliCostModelGetLiteralCosts(model, posdata->pos, pos));
|
443
|
+
min_len = ComputeMinimumCopyLength(min_cost, nodes, num_bytes, pos);
|
444
|
+
}
|
445
|
+
|
446
|
+
/* Go over the command starting positions in order of increasing cost
|
447
|
+
difference. */
|
448
|
+
for (k = 0; k < max_iters && k < StartPosQueueSize(queue); ++k) {
|
449
|
+
const PosData* posdata = StartPosQueueAt(queue, k);
|
450
|
+
const size_t start = posdata->pos;
|
451
|
+
const uint16_t inscode = GetInsertLengthCode(pos - start);
|
452
|
+
const float start_costdiff = posdata->costdiff;
|
453
|
+
const float base_cost = start_costdiff + (float)GetInsertExtra(inscode) +
|
454
|
+
ZopfliCostModelGetLiteralCosts(model, 0, pos);
|
455
|
+
|
456
|
+
/* Look for last distance matches using the distance cache from this
|
457
|
+
starting position. */
|
458
|
+
size_t best_len = min_len - 1;
|
459
|
+
size_t j = 0;
|
460
|
+
for (; j < BROTLI_NUM_DISTANCE_SHORT_CODES && best_len < max_len; ++j) {
|
461
|
+
const size_t idx = kDistanceCacheIndex[j];
|
462
|
+
const size_t backward =
|
463
|
+
(size_t)(posdata->distance_cache[idx] + kDistanceCacheOffset[j]);
|
464
|
+
size_t prev_ix = cur_ix - backward;
|
465
|
+
size_t len = 0;
|
466
|
+
uint8_t continuation = ringbuffer[cur_ix_masked + best_len];
|
467
|
+
if (cur_ix_masked + best_len > ringbuffer_mask) {
|
468
|
+
break;
|
469
|
+
}
|
470
|
+
if (BROTLI_PREDICT_FALSE(backward > dictionary_start + gap)) {
|
471
|
+
/* Word dictionary -> ignore. */
|
472
|
+
continue;
|
473
|
+
}
|
474
|
+
if (backward <= max_distance) {
|
475
|
+
/* Regular backward reference. */
|
476
|
+
if (prev_ix >= cur_ix) {
|
477
|
+
continue;
|
478
|
+
}
|
479
|
+
|
480
|
+
prev_ix &= ringbuffer_mask;
|
481
|
+
if (prev_ix + best_len > ringbuffer_mask ||
|
482
|
+
continuation != ringbuffer[prev_ix + best_len]) {
|
483
|
+
continue;
|
484
|
+
}
|
485
|
+
len = FindMatchLengthWithLimit(&ringbuffer[prev_ix],
|
486
|
+
&ringbuffer[cur_ix_masked],
|
487
|
+
max_len);
|
488
|
+
} else if (backward > dictionary_start) {
|
489
|
+
size_t d = 0;
|
490
|
+
size_t offset;
|
491
|
+
size_t limit;
|
492
|
+
const uint8_t* source;
|
493
|
+
offset = dictionary_start + 1 + addon->total_size - 1;
|
494
|
+
while (offset >= backward + addon->chunk_offsets[d + 1]) d++;
|
495
|
+
source = addon->chunk_source[d];
|
496
|
+
offset = offset - addon->chunk_offsets[d] - backward;
|
497
|
+
limit = addon->chunk_offsets[d + 1] - addon->chunk_offsets[d] - offset;
|
498
|
+
limit = limit > max_len ? max_len : limit;
|
499
|
+
if (best_len >= limit ||
|
500
|
+
continuation != source[offset + best_len]) {
|
501
|
+
continue;
|
502
|
+
}
|
503
|
+
len = FindMatchLengthWithLimit(&source[offset],
|
504
|
+
&ringbuffer[cur_ix_masked],
|
505
|
+
limit);
|
506
|
+
} else {
|
507
|
+
/* "Gray" area. It is addressable by decoder, but this encoder
|
508
|
+
instance does not have that data -> should not touch it. */
|
509
|
+
continue;
|
510
|
+
}
|
511
|
+
{
|
512
|
+
const float dist_cost = base_cost +
|
513
|
+
ZopfliCostModelGetDistanceCost(model, j);
|
514
|
+
size_t l;
|
515
|
+
for (l = best_len + 1; l <= len; ++l) {
|
516
|
+
const uint16_t copycode = GetCopyLengthCode(l);
|
517
|
+
const uint16_t cmdcode =
|
518
|
+
CombineLengthCodes(inscode, copycode, j == 0);
|
519
|
+
const float cost = (cmdcode < 128 ? base_cost : dist_cost) +
|
520
|
+
(float)GetCopyExtra(copycode) +
|
521
|
+
ZopfliCostModelGetCommandCost(model, cmdcode);
|
522
|
+
if (cost < nodes[pos + l].u.cost) {
|
523
|
+
UpdateZopfliNode(nodes, pos, start, l, l, backward, j + 1, cost);
|
524
|
+
result = BROTLI_MAX(size_t, result, l);
|
525
|
+
}
|
526
|
+
best_len = l;
|
527
|
+
}
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
/* At higher iterations look only for new last distance matches, since
|
532
|
+
looking only for new command start positions with the same distances
|
533
|
+
does not help much. */
|
534
|
+
if (k >= 2) continue;
|
535
|
+
|
536
|
+
{
|
537
|
+
/* Loop through all possible copy lengths at this position. */
|
538
|
+
size_t len = min_len;
|
539
|
+
for (j = 0; j < num_matches; ++j) {
|
540
|
+
BackwardMatch match = matches[j];
|
541
|
+
size_t dist = match.distance;
|
542
|
+
BROTLI_BOOL is_dictionary_match =
|
543
|
+
TO_BROTLI_BOOL(dist > dictionary_start + gap);
|
544
|
+
/* We already tried all possible last distance matches, so we can use
|
545
|
+
normal distance code here. */
|
546
|
+
size_t dist_code = dist + BROTLI_NUM_DISTANCE_SHORT_CODES - 1;
|
547
|
+
uint16_t dist_symbol;
|
548
|
+
uint32_t distextra;
|
549
|
+
uint32_t distnumextra;
|
550
|
+
float dist_cost;
|
551
|
+
size_t max_match_len;
|
552
|
+
PrefixEncodeCopyDistance(
|
553
|
+
dist_code, params->dist.num_direct_distance_codes,
|
554
|
+
params->dist.distance_postfix_bits, &dist_symbol, &distextra);
|
555
|
+
distnumextra = dist_symbol >> 10;
|
556
|
+
dist_cost = base_cost + (float)distnumextra +
|
557
|
+
ZopfliCostModelGetDistanceCost(model, dist_symbol & 0x3FF);
|
558
|
+
|
559
|
+
/* Try all copy lengths up until the maximum copy length corresponding
|
560
|
+
to this distance. If the distance refers to the static dictionary, or
|
561
|
+
the maximum length is long enough, try only one maximum length. */
|
562
|
+
max_match_len = BackwardMatchLength(&match);
|
563
|
+
if (len < max_match_len &&
|
564
|
+
(is_dictionary_match || max_match_len > max_zopfli_len)) {
|
565
|
+
len = max_match_len;
|
566
|
+
}
|
567
|
+
for (; len <= max_match_len; ++len) {
|
568
|
+
const size_t len_code =
|
569
|
+
is_dictionary_match ? BackwardMatchLengthCode(&match) : len;
|
570
|
+
const uint16_t copycode = GetCopyLengthCode(len_code);
|
571
|
+
const uint16_t cmdcode = CombineLengthCodes(inscode, copycode, 0);
|
572
|
+
const float cost = dist_cost + (float)GetCopyExtra(copycode) +
|
573
|
+
ZopfliCostModelGetCommandCost(model, cmdcode);
|
574
|
+
if (cost < nodes[pos + len].u.cost) {
|
575
|
+
UpdateZopfliNode(nodes, pos, start, len, len_code, dist, 0, cost);
|
576
|
+
result = BROTLI_MAX(size_t, result, len);
|
577
|
+
}
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}
|
581
|
+
}
|
582
|
+
return result;
|
583
|
+
}
|
584
|
+
|
585
|
+
static size_t ComputeShortestPathFromNodes(size_t num_bytes,
|
586
|
+
ZopfliNode* nodes) {
|
587
|
+
size_t index = num_bytes;
|
588
|
+
size_t num_commands = 0;
|
589
|
+
while ((nodes[index].dcode_insert_length & 0x7FFFFFF) == 0 &&
|
590
|
+
nodes[index].length == 1) --index;
|
591
|
+
nodes[index].u.next = BROTLI_UINT32_MAX;
|
592
|
+
while (index != 0) {
|
593
|
+
size_t len = ZopfliNodeCommandLength(&nodes[index]);
|
594
|
+
index -= len;
|
595
|
+
nodes[index].u.next = (uint32_t)len;
|
596
|
+
num_commands++;
|
597
|
+
}
|
598
|
+
return num_commands;
|
599
|
+
}
|
600
|
+
|
601
|
+
/* REQUIRES: nodes != NULL and len(nodes) >= num_bytes + 1 */
|
602
|
+
void duckdb_brotli::BrotliZopfliCreateCommands(const size_t num_bytes,
|
603
|
+
const size_t block_start, const ZopfliNode* nodes, int* dist_cache,
|
604
|
+
size_t* last_insert_len, const BrotliEncoderParams* params,
|
605
|
+
Command* commands, size_t* num_literals) {
|
606
|
+
const size_t stream_offset = params->stream_offset;
|
607
|
+
const size_t max_backward_limit = BROTLI_MAX_BACKWARD_LIMIT(params->lgwin);
|
608
|
+
size_t pos = 0;
|
609
|
+
uint32_t offset = nodes[0].u.next;
|
610
|
+
size_t i;
|
611
|
+
size_t gap = params->dictionary.compound.total_size;
|
612
|
+
for (i = 0; offset != BROTLI_UINT32_MAX; i++) {
|
613
|
+
const ZopfliNode* next = &nodes[pos + offset];
|
614
|
+
size_t copy_length = ZopfliNodeCopyLength(next);
|
615
|
+
size_t insert_length = next->dcode_insert_length & 0x7FFFFFF;
|
616
|
+
pos += insert_length;
|
617
|
+
offset = next->u.next;
|
618
|
+
if (i == 0) {
|
619
|
+
insert_length += *last_insert_len;
|
620
|
+
*last_insert_len = 0;
|
621
|
+
}
|
622
|
+
{
|
623
|
+
size_t distance = ZopfliNodeCopyDistance(next);
|
624
|
+
size_t len_code = ZopfliNodeLengthCode(next);
|
625
|
+
size_t dictionary_start = BROTLI_MIN(size_t,
|
626
|
+
block_start + pos + stream_offset, max_backward_limit);
|
627
|
+
BROTLI_BOOL is_dictionary =
|
628
|
+
TO_BROTLI_BOOL(distance > dictionary_start + gap);
|
629
|
+
size_t dist_code = ZopfliNodeDistanceCode(next);
|
630
|
+
InitCommand(&commands[i], ¶ms->dist, insert_length,
|
631
|
+
copy_length, (int)len_code - (int)copy_length, dist_code);
|
632
|
+
|
633
|
+
if (!is_dictionary && dist_code > 0) {
|
634
|
+
dist_cache[3] = dist_cache[2];
|
635
|
+
dist_cache[2] = dist_cache[1];
|
636
|
+
dist_cache[1] = dist_cache[0];
|
637
|
+
dist_cache[0] = (int)distance;
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
641
|
+
*num_literals += insert_length;
|
642
|
+
pos += copy_length;
|
643
|
+
}
|
644
|
+
*last_insert_len += num_bytes - pos;
|
645
|
+
}
|
646
|
+
|
647
|
+
static size_t ZopfliIterate(size_t num_bytes, size_t position,
|
648
|
+
const uint8_t* ringbuffer, size_t ringbuffer_mask,
|
649
|
+
const BrotliEncoderParams* params, const size_t gap, const int* dist_cache,
|
650
|
+
const ZopfliCostModel* model, const uint32_t* num_matches,
|
651
|
+
const BackwardMatch* matches, ZopfliNode* nodes) {
|
652
|
+
const size_t stream_offset = params->stream_offset;
|
653
|
+
const size_t max_backward_limit = BROTLI_MAX_BACKWARD_LIMIT(params->lgwin);
|
654
|
+
const size_t max_zopfli_len = MaxZopfliLen(params);
|
655
|
+
StartPosQueue queue;
|
656
|
+
size_t cur_match_pos = 0;
|
657
|
+
size_t i;
|
658
|
+
nodes[0].length = 0;
|
659
|
+
nodes[0].u.cost = 0;
|
660
|
+
InitStartPosQueue(&queue);
|
661
|
+
for (i = 0; i + 3 < num_bytes; i++) {
|
662
|
+
size_t skip = UpdateNodes(num_bytes, position, i, ringbuffer,
|
663
|
+
ringbuffer_mask, params, max_backward_limit, dist_cache,
|
664
|
+
num_matches[i], &matches[cur_match_pos], model, &queue, nodes);
|
665
|
+
if (skip < BROTLI_LONG_COPY_QUICK_STEP) skip = 0;
|
666
|
+
cur_match_pos += num_matches[i];
|
667
|
+
if (num_matches[i] == 1 &&
|
668
|
+
BackwardMatchLength(&matches[cur_match_pos - 1]) > max_zopfli_len) {
|
669
|
+
skip = BROTLI_MAX(size_t,
|
670
|
+
BackwardMatchLength(&matches[cur_match_pos - 1]), skip);
|
671
|
+
}
|
672
|
+
if (skip > 1) {
|
673
|
+
skip--;
|
674
|
+
while (skip) {
|
675
|
+
i++;
|
676
|
+
if (i + 3 >= num_bytes) break;
|
677
|
+
EvaluateNode(position + stream_offset, i, max_backward_limit, gap,
|
678
|
+
dist_cache, model, &queue, nodes);
|
679
|
+
cur_match_pos += num_matches[i];
|
680
|
+
skip--;
|
681
|
+
}
|
682
|
+
}
|
683
|
+
}
|
684
|
+
return ComputeShortestPathFromNodes(num_bytes, nodes);
|
685
|
+
}
|
686
|
+
|
687
|
+
static void MergeMatches(BackwardMatch* dst,
|
688
|
+
BackwardMatch* src1, size_t len1, BackwardMatch* src2, size_t len2) {
|
689
|
+
while (len1 > 0 && len2 > 0) {
|
690
|
+
size_t l1 = BackwardMatchLength(src1);
|
691
|
+
size_t l2 = BackwardMatchLength(src2);
|
692
|
+
if (l1 < l2 || ((l1 == l2) && (src1->distance < src2->distance))) {
|
693
|
+
*dst++ = *src1++;
|
694
|
+
len1--;
|
695
|
+
} else {
|
696
|
+
*dst++ = *src2++;
|
697
|
+
len2--;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
while (len1-- > 0) *dst++ = *src1++;
|
701
|
+
while (len2-- > 0) *dst++ = *src2++;
|
702
|
+
}
|
703
|
+
|
704
|
+
/* REQUIRES: nodes != NULL and len(nodes) >= num_bytes + 1 */
|
705
|
+
size_t duckdb_brotli::BrotliZopfliComputeShortestPath(MemoryManager* m, size_t num_bytes,
|
706
|
+
size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
|
707
|
+
ContextLut literal_context_lut, const BrotliEncoderParams* params,
|
708
|
+
const int* dist_cache, Hasher* hasher, ZopfliNode* nodes) {
|
709
|
+
const size_t stream_offset = params->stream_offset;
|
710
|
+
const size_t max_backward_limit = BROTLI_MAX_BACKWARD_LIMIT(params->lgwin);
|
711
|
+
const size_t max_zopfli_len = MaxZopfliLen(params);
|
712
|
+
StartPosQueue queue;
|
713
|
+
BackwardMatch* BROTLI_RESTRICT matches =
|
714
|
+
BROTLI_ALLOC(m, BackwardMatch, 2 * (MAX_NUM_MATCHES_H10 + 64));
|
715
|
+
const size_t store_end = num_bytes >= StoreLookaheadH10() ?
|
716
|
+
position + num_bytes - StoreLookaheadH10() + 1 : position;
|
717
|
+
size_t i;
|
718
|
+
const CompoundDictionary* addon = ¶ms->dictionary.compound;
|
719
|
+
size_t gap = addon->total_size;
|
720
|
+
size_t lz_matches_offset =
|
721
|
+
(addon->num_chunks != 0) ? (MAX_NUM_MATCHES_H10 + 128) : 0;
|
722
|
+
ZopfliCostModel* model = BROTLI_ALLOC(m, ZopfliCostModel, 1);
|
723
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(model) || BROTLI_IS_NULL(matches)) {
|
724
|
+
return 0;
|
725
|
+
}
|
726
|
+
nodes[0].length = 0;
|
727
|
+
nodes[0].u.cost = 0;
|
728
|
+
InitZopfliCostModel(m, model, ¶ms->dist, num_bytes);
|
729
|
+
if (BROTLI_IS_OOM(m)) return 0;
|
730
|
+
ZopfliCostModelSetFromLiteralCosts(
|
731
|
+
model, position, ringbuffer, ringbuffer_mask);
|
732
|
+
InitStartPosQueue(&queue);
|
733
|
+
for (i = 0; i + HashTypeLengthH10() - 1 < num_bytes; i++) {
|
734
|
+
const size_t pos = position + i;
|
735
|
+
const size_t max_distance = BROTLI_MIN(size_t, pos, max_backward_limit);
|
736
|
+
const size_t dictionary_start = BROTLI_MIN(size_t,
|
737
|
+
pos + stream_offset, max_backward_limit);
|
738
|
+
size_t skip;
|
739
|
+
size_t num_matches;
|
740
|
+
int dict_id = 0;
|
741
|
+
if (params->dictionary.contextual.context_based) {
|
742
|
+
uint8_t p1 = pos >= 1 ?
|
743
|
+
ringbuffer[(size_t)(pos - 1) & ringbuffer_mask] : 0;
|
744
|
+
uint8_t p2 = pos >= 2 ?
|
745
|
+
ringbuffer[(size_t)(pos - 2) & ringbuffer_mask] : 0;
|
746
|
+
dict_id = params->dictionary.contextual.context_map[
|
747
|
+
BROTLI_CONTEXT(p1, p2, literal_context_lut)];
|
748
|
+
}
|
749
|
+
num_matches = FindAllMatchesH10(&hasher->privat._H10,
|
750
|
+
params->dictionary.contextual.dict[dict_id],
|
751
|
+
ringbuffer, ringbuffer_mask, pos, num_bytes - i, max_distance,
|
752
|
+
dictionary_start + gap, params, &matches[lz_matches_offset]);
|
753
|
+
if (addon->num_chunks != 0) {
|
754
|
+
size_t cd_matches = LookupAllCompoundDictionaryMatches(addon,
|
755
|
+
ringbuffer, ringbuffer_mask, pos, 3, num_bytes - i,
|
756
|
+
dictionary_start, params->dist.max_distance,
|
757
|
+
&matches[lz_matches_offset - 64], 64);
|
758
|
+
MergeMatches(matches, &matches[lz_matches_offset - 64], cd_matches,
|
759
|
+
&matches[lz_matches_offset], num_matches);
|
760
|
+
num_matches += cd_matches;
|
761
|
+
}
|
762
|
+
if (num_matches > 0 &&
|
763
|
+
BackwardMatchLength(&matches[num_matches - 1]) > max_zopfli_len) {
|
764
|
+
matches[0] = matches[num_matches - 1];
|
765
|
+
num_matches = 1;
|
766
|
+
}
|
767
|
+
skip = UpdateNodes(num_bytes, position, i, ringbuffer, ringbuffer_mask,
|
768
|
+
params, max_backward_limit, dist_cache, num_matches, matches, model,
|
769
|
+
&queue, nodes);
|
770
|
+
if (skip < BROTLI_LONG_COPY_QUICK_STEP) skip = 0;
|
771
|
+
if (num_matches == 1 && BackwardMatchLength(&matches[0]) > max_zopfli_len) {
|
772
|
+
skip = BROTLI_MAX(size_t, BackwardMatchLength(&matches[0]), skip);
|
773
|
+
}
|
774
|
+
if (skip > 1) {
|
775
|
+
/* Add the tail of the copy to the hasher. */
|
776
|
+
StoreRangeH10(&hasher->privat._H10,
|
777
|
+
ringbuffer, ringbuffer_mask, pos + 1, BROTLI_MIN(
|
778
|
+
size_t, pos + skip, store_end));
|
779
|
+
skip--;
|
780
|
+
while (skip) {
|
781
|
+
i++;
|
782
|
+
if (i + HashTypeLengthH10() - 1 >= num_bytes) break;
|
783
|
+
EvaluateNode(position + stream_offset, i, max_backward_limit, gap,
|
784
|
+
dist_cache, model, &queue, nodes);
|
785
|
+
skip--;
|
786
|
+
}
|
787
|
+
}
|
788
|
+
}
|
789
|
+
CleanupZopfliCostModel(m, model);
|
790
|
+
BROTLI_FREE(m, model);
|
791
|
+
BROTLI_FREE(m, matches);
|
792
|
+
return ComputeShortestPathFromNodes(num_bytes, nodes);
|
793
|
+
}
|
794
|
+
|
795
|
+
void duckdb_brotli::BrotliCreateZopfliBackwardReferences(MemoryManager* m, size_t num_bytes,
|
796
|
+
size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
|
797
|
+
ContextLut literal_context_lut, const BrotliEncoderParams* params,
|
798
|
+
Hasher* hasher, int* dist_cache, size_t* last_insert_len,
|
799
|
+
Command* commands, size_t* num_commands, size_t* num_literals) {
|
800
|
+
ZopfliNode* nodes = BROTLI_ALLOC(m, ZopfliNode, num_bytes + 1);
|
801
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(nodes)) return;
|
802
|
+
BrotliInitZopfliNodes(nodes, num_bytes + 1);
|
803
|
+
*num_commands += BrotliZopfliComputeShortestPath(m, num_bytes,
|
804
|
+
position, ringbuffer, ringbuffer_mask, literal_context_lut, params,
|
805
|
+
dist_cache, hasher, nodes);
|
806
|
+
if (BROTLI_IS_OOM(m)) return;
|
807
|
+
BrotliZopfliCreateCommands(num_bytes, position, nodes, dist_cache,
|
808
|
+
last_insert_len, params, commands, num_literals);
|
809
|
+
BROTLI_FREE(m, nodes);
|
810
|
+
}
|
811
|
+
|
812
|
+
void duckdb_brotli::BrotliCreateHqZopfliBackwardReferences(MemoryManager* m, size_t num_bytes,
|
813
|
+
size_t position, const uint8_t* ringbuffer, size_t ringbuffer_mask,
|
814
|
+
ContextLut literal_context_lut, const BrotliEncoderParams* params,
|
815
|
+
Hasher* hasher, int* dist_cache, size_t* last_insert_len,
|
816
|
+
Command* commands, size_t* num_commands, size_t* num_literals) {
|
817
|
+
const size_t stream_offset = params->stream_offset;
|
818
|
+
const size_t max_backward_limit = BROTLI_MAX_BACKWARD_LIMIT(params->lgwin);
|
819
|
+
uint32_t* num_matches = BROTLI_ALLOC(m, uint32_t, num_bytes);
|
820
|
+
size_t matches_size = 4 * num_bytes;
|
821
|
+
const size_t store_end = num_bytes >= StoreLookaheadH10() ?
|
822
|
+
position + num_bytes - StoreLookaheadH10() + 1 : position;
|
823
|
+
size_t cur_match_pos = 0;
|
824
|
+
size_t i;
|
825
|
+
size_t orig_num_literals;
|
826
|
+
size_t orig_last_insert_len;
|
827
|
+
int orig_dist_cache[4];
|
828
|
+
size_t orig_num_commands;
|
829
|
+
ZopfliCostModel* model = BROTLI_ALLOC(m, ZopfliCostModel, 1);
|
830
|
+
ZopfliNode* nodes;
|
831
|
+
BackwardMatch* matches = BROTLI_ALLOC(m, BackwardMatch, matches_size);
|
832
|
+
const CompoundDictionary* addon = ¶ms->dictionary.compound;
|
833
|
+
size_t gap = addon->total_size;
|
834
|
+
size_t shadow_matches =
|
835
|
+
(addon->num_chunks != 0) ? (MAX_NUM_MATCHES_H10 + 128) : 0;
|
836
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(model) ||
|
837
|
+
BROTLI_IS_NULL(num_matches) || BROTLI_IS_NULL(matches)) {
|
838
|
+
return;
|
839
|
+
}
|
840
|
+
for (i = 0; i + HashTypeLengthH10() - 1 < num_bytes; ++i) {
|
841
|
+
const size_t pos = position + i;
|
842
|
+
size_t max_distance = BROTLI_MIN(size_t, pos, max_backward_limit);
|
843
|
+
size_t dictionary_start = BROTLI_MIN(size_t,
|
844
|
+
pos + stream_offset, max_backward_limit);
|
845
|
+
size_t max_length = num_bytes - i;
|
846
|
+
size_t num_found_matches;
|
847
|
+
size_t cur_match_end;
|
848
|
+
size_t j;
|
849
|
+
int dict_id = 0;
|
850
|
+
if (params->dictionary.contextual.context_based) {
|
851
|
+
uint8_t p1 = pos >= 1 ?
|
852
|
+
ringbuffer[(size_t)(pos - 1) & ringbuffer_mask] : 0;
|
853
|
+
uint8_t p2 = pos >= 2 ?
|
854
|
+
ringbuffer[(size_t)(pos - 2) & ringbuffer_mask] : 0;
|
855
|
+
dict_id = params->dictionary.contextual.context_map[
|
856
|
+
BROTLI_CONTEXT(p1, p2, literal_context_lut)];
|
857
|
+
}
|
858
|
+
/* Ensure that we have enough free slots. */
|
859
|
+
BROTLI_ENSURE_CAPACITY(m, BackwardMatch, matches, matches_size,
|
860
|
+
cur_match_pos + MAX_NUM_MATCHES_H10 + shadow_matches);
|
861
|
+
if (BROTLI_IS_OOM(m)) return;
|
862
|
+
num_found_matches = FindAllMatchesH10(&hasher->privat._H10,
|
863
|
+
params->dictionary.contextual.dict[dict_id],
|
864
|
+
ringbuffer, ringbuffer_mask, pos, max_length,
|
865
|
+
max_distance, dictionary_start + gap, params,
|
866
|
+
&matches[cur_match_pos + shadow_matches]);
|
867
|
+
if (addon->num_chunks != 0) {
|
868
|
+
size_t cd_matches = LookupAllCompoundDictionaryMatches(addon,
|
869
|
+
ringbuffer, ringbuffer_mask, pos, 3, max_length,
|
870
|
+
dictionary_start, params->dist.max_distance,
|
871
|
+
&matches[cur_match_pos + shadow_matches - 64], 64);
|
872
|
+
MergeMatches(&matches[cur_match_pos],
|
873
|
+
&matches[cur_match_pos + shadow_matches - 64], cd_matches,
|
874
|
+
&matches[cur_match_pos + shadow_matches], num_found_matches);
|
875
|
+
num_found_matches += cd_matches;
|
876
|
+
}
|
877
|
+
cur_match_end = cur_match_pos + num_found_matches;
|
878
|
+
for (j = cur_match_pos; j + 1 < cur_match_end; ++j) {
|
879
|
+
BROTLI_DCHECK(BackwardMatchLength(&matches[j]) <=
|
880
|
+
BackwardMatchLength(&matches[j + 1]));
|
881
|
+
}
|
882
|
+
num_matches[i] = (uint32_t)num_found_matches;
|
883
|
+
if (num_found_matches > 0) {
|
884
|
+
const size_t match_len = BackwardMatchLength(&matches[cur_match_end - 1]);
|
885
|
+
if (match_len > MAX_ZOPFLI_LEN_QUALITY_11) {
|
886
|
+
const size_t skip = match_len - 1;
|
887
|
+
matches[cur_match_pos++] = matches[cur_match_end - 1];
|
888
|
+
num_matches[i] = 1;
|
889
|
+
/* Add the tail of the copy to the hasher. */
|
890
|
+
StoreRangeH10(&hasher->privat._H10,
|
891
|
+
ringbuffer, ringbuffer_mask, pos + 1,
|
892
|
+
BROTLI_MIN(size_t, pos + match_len, store_end));
|
893
|
+
memset(&num_matches[i + 1], 0, skip * sizeof(num_matches[0]));
|
894
|
+
i += skip;
|
895
|
+
} else {
|
896
|
+
cur_match_pos = cur_match_end;
|
897
|
+
}
|
898
|
+
}
|
899
|
+
}
|
900
|
+
orig_num_literals = *num_literals;
|
901
|
+
orig_last_insert_len = *last_insert_len;
|
902
|
+
memcpy(orig_dist_cache, dist_cache, 4 * sizeof(dist_cache[0]));
|
903
|
+
orig_num_commands = *num_commands;
|
904
|
+
nodes = BROTLI_ALLOC(m, ZopfliNode, num_bytes + 1);
|
905
|
+
if (BROTLI_IS_OOM(m) || BROTLI_IS_NULL(nodes)) return;
|
906
|
+
InitZopfliCostModel(m, model, ¶ms->dist, num_bytes);
|
907
|
+
if (BROTLI_IS_OOM(m)) return;
|
908
|
+
for (i = 0; i < 2; i++) {
|
909
|
+
BrotliInitZopfliNodes(nodes, num_bytes + 1);
|
910
|
+
if (i == 0) {
|
911
|
+
ZopfliCostModelSetFromLiteralCosts(
|
912
|
+
model, position, ringbuffer, ringbuffer_mask);
|
913
|
+
} else {
|
914
|
+
ZopfliCostModelSetFromCommands(model, position, ringbuffer,
|
915
|
+
ringbuffer_mask, commands, *num_commands - orig_num_commands,
|
916
|
+
orig_last_insert_len);
|
917
|
+
}
|
918
|
+
*num_commands = orig_num_commands;
|
919
|
+
*num_literals = orig_num_literals;
|
920
|
+
*last_insert_len = orig_last_insert_len;
|
921
|
+
memcpy(dist_cache, orig_dist_cache, 4 * sizeof(dist_cache[0]));
|
922
|
+
*num_commands += ZopfliIterate(num_bytes, position, ringbuffer,
|
923
|
+
ringbuffer_mask, params, gap, dist_cache, model, num_matches, matches,
|
924
|
+
nodes);
|
925
|
+
BrotliZopfliCreateCommands(num_bytes, position, nodes, dist_cache,
|
926
|
+
last_insert_len, params, commands, num_literals);
|
927
|
+
}
|
928
|
+
CleanupZopfliCostModel(m, model);
|
929
|
+
BROTLI_FREE(m, model);
|
930
|
+
BROTLI_FREE(m, nodes);
|
931
|
+
BROTLI_FREE(m, matches);
|
932
|
+
BROTLI_FREE(m, num_matches);
|
933
|
+
}
|
934
|
+
|
935
|
+
|