duckdb 0.7.2-dev16.0 → 0.7.2-dev314.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +2 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +2 -0
- package/src/duckdb/extension/icu/icu-table-range.cpp +194 -0
- package/src/duckdb/extension/icu/include/icu-table-range.hpp +17 -0
- package/src/duckdb/extension/parquet/column_reader.cpp +5 -6
- package/src/duckdb/extension/parquet/column_writer.cpp +0 -1
- package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -2
- package/src/duckdb/extension/parquet/include/generated_column_reader.hpp +1 -11
- package/src/duckdb/extension/parquet/parquet-extension.cpp +11 -2
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +26 -32
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +4 -0
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +7 -6
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +20 -1
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/sort/sort_state.cpp +5 -7
- package/src/duckdb/src/common/types/bit.cpp +95 -58
- package/src/duckdb/src/common/types/value.cpp +149 -53
- package/src/duckdb/src/common/types/vector.cpp +13 -10
- package/src/duckdb/src/execution/column_binding_resolver.cpp +6 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +4 -5
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +2 -3
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +32 -6
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +15 -15
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +18 -12
- package/src/duckdb/src/function/aggregate/algebraic/avg.cpp +0 -6
- package/src/duckdb/src/function/aggregate/distributive/bitagg.cpp +99 -95
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +254 -0
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +2 -4
- package/src/duckdb/src/function/aggregate/distributive/sum.cpp +11 -16
- package/src/duckdb/src/function/aggregate/distributive_functions.cpp +1 -0
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +16 -5
- package/src/duckdb/src/function/cast/bit_cast.cpp +0 -2
- package/src/duckdb/src/function/cast/blob_cast.cpp +0 -1
- package/src/duckdb/src/function/scalar/bit/bitstring.cpp +99 -0
- package/src/duckdb/src/function/scalar/date/date_diff.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +17 -25
- package/src/duckdb/src/function/scalar/date/date_sub.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_trunc.cpp +10 -14
- package/src/duckdb/src/function/scalar/generic/stats.cpp +2 -4
- package/src/duckdb/src/function/scalar/list/flatten.cpp +5 -12
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +3 -8
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +5 -12
- package/src/duckdb/src/function/scalar/list/list_value.cpp +5 -9
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +61 -0
- package/src/duckdb/src/function/scalar/map/map_keys_values.cpp +97 -0
- package/src/duckdb/src/function/scalar/math/numeric.cpp +14 -17
- package/src/duckdb/src/function/scalar/nested_functions.cpp +3 -0
- package/src/duckdb/src/function/scalar/operators/add.cpp +0 -9
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +29 -48
- package/src/duckdb/src/function/scalar/operators/bitwise.cpp +0 -63
- package/src/duckdb/src/function/scalar/operators/multiply.cpp +0 -6
- package/src/duckdb/src/function/scalar/operators/subtract.cpp +0 -6
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/instr.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/length.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/like.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/substring.cpp +2 -6
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +4 -9
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +10 -13
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +5 -6
- package/src/duckdb/src/function/table/read_csv.cpp +9 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/table_function.cpp +19 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +6 -8
- package/src/duckdb/src/include/duckdb/common/constants.hpp +0 -19
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/tableref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -8
- package/src/duckdb/src/include/duckdb/common/types.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +5 -0
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +12 -3
- package/src/duckdb/src/include/duckdb/function/scalar/bit_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +12 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/{alter_function_info.hpp → alter_scalar_function_info.hpp} +13 -13
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_function_info.hpp +47 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/statement/multi_statement.hpp +28 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +76 -0
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +28 -0
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +8 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +76 -44
- package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_fetch.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_fetch.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 +5 -2
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +93 -29
- package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +22 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +6 -6
- package/src/duckdb/src/include/duckdb/storage/statistics/list_stats.hpp +41 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/node_statistics.hpp +26 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +157 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/segment_statistics.hpp +2 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +74 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_stats.hpp +42 -0
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +2 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +5 -0
- package/src/duckdb/src/include/duckdb.h +49 -1
- package/src/duckdb/src/include/duckdb.hpp +0 -1
- package/src/duckdb/src/main/capi/pending-c.cpp +16 -3
- package/src/duckdb/src/main/capi/result-c.cpp +27 -1
- package/src/duckdb/src/main/capi/stream-c.cpp +25 -0
- package/src/duckdb/src/main/client_context.cpp +8 -1
- package/src/duckdb/src/main/config.cpp +66 -1
- package/src/duckdb/src/main/database.cpp +10 -2
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +98 -67
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +16 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_aggregate.cpp +9 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +6 -7
- package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +14 -11
- package/src/duckdb/src/optimizer/statistics/expression/propagate_columnref.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +13 -15
- package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +0 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_constant.cpp +3 -75
- package/src/duckdb/src/optimizer/statistics/expression/propagate_function.cpp +7 -2
- package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +10 -0
- package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +2 -3
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +28 -31
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +4 -5
- package/src/duckdb/src/optimizer/statistics/operator/propagate_set_operation.cpp +3 -3
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +7 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +56 -0
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +51 -0
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +6 -0
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +8 -0
- package/src/duckdb/src/parser/query_node.cpp +1 -1
- package/src/duckdb/src/parser/statement/multi_statement.cpp +18 -0
- package/src/duckdb/src/parser/tableref/pivotref.cpp +296 -0
- package/src/duckdb/src/parser/tableref.cpp +3 -0
- package/src/duckdb/src/parser/transform/helpers/transform_alias.cpp +12 -6
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +24 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +150 -0
- package/src/duckdb/src/parser/transform/statement/transform_select.cpp +8 -0
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +4 -0
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +105 -0
- package/src/duckdb/src/parser/transform/tableref/transform_tableref.cpp +2 -0
- package/src/duckdb/src/parser/transformer.cpp +15 -3
- package/src/duckdb/src/planner/bind_context.cpp +16 -0
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +11 -3
- package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +0 -1
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_logical_plan.cpp +17 -0
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +9 -0
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +365 -0
- package/src/duckdb/src/planner/binder.cpp +7 -1
- package/src/duckdb/src/planner/bound_result_modifier.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +1 -1
- package/src/duckdb/src/planner/filter/constant_filter.cpp +4 -6
- package/src/duckdb/src/planner/pragma_handler.cpp +10 -2
- package/src/duckdb/src/storage/buffer_manager.cpp +44 -46
- package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +1 -1
- package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +1 -4
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +4 -4
- package/src/duckdb/src/storage/compression/bitpacking.cpp +28 -24
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +43 -45
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +9 -10
- package/src/duckdb/src/storage/compression/patas.cpp +1 -1
- package/src/duckdb/src/storage/compression/rle.cpp +19 -15
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +5 -5
- package/src/duckdb/src/storage/data_table.cpp +4 -6
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +373 -128
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +58 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +4 -9
- package/src/duckdb/src/storage/statistics/list_stats.cpp +117 -0
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +529 -0
- package/src/duckdb/src/storage/statistics/segment_statistics.cpp +2 -11
- package/src/duckdb/src/storage/statistics/string_stats.cpp +273 -0
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +131 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +3 -4
- package/src/duckdb/src/storage/table/column_data.cpp +16 -11
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +2 -3
- package/src/duckdb/src/storage/table/column_segment.cpp +6 -8
- package/src/duckdb/src/storage/table/list_column_data.cpp +39 -58
- package/src/duckdb/src/storage/table/row_group.cpp +24 -23
- package/src/duckdb/src/storage/table/row_group_collection.cpp +12 -12
- package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -6
- package/src/duckdb/src/storage/table/struct_column_data.cpp +15 -16
- package/src/duckdb/src/storage/table/table_statistics.cpp +27 -7
- package/src/duckdb/src/storage/table/update_segment.cpp +10 -12
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +3 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +34 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1020 -530
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +7 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +23560 -22737
- package/src/duckdb/ub_src_function_aggregate_distributive.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_bit.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_map.cpp +4 -0
- package/src/duckdb/ub_src_main_capi.cpp +2 -0
- package/src/duckdb/ub_src_parser_parsed_data.cpp +4 -2
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_tableref.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +2 -0
- package/src/duckdb/ub_src_storage_statistics.cpp +4 -6
- package/src/duckdb/src/include/duckdb/main/loadable_extension.hpp +0 -59
- package/src/duckdb/src/include/duckdb/storage/statistics/list_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_statistics.hpp +0 -75
- package/src/duckdb/src/include/duckdb/storage/statistics/string_statistics.hpp +0 -49
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/validity_statistics.hpp +0 -45
- package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +0 -55
- package/src/duckdb/src/storage/statistics/list_statistics.cpp +0 -94
- package/src/duckdb/src/storage/statistics/numeric_statistics.cpp +0 -307
- package/src/duckdb/src/storage/statistics/string_statistics.cpp +0 -220
- package/src/duckdb/src/storage/statistics/struct_statistics.cpp +0 -108
- package/src/duckdb/src/storage/statistics/validity_statistics.cpp +0 -91
@@ -3,8 +3,10 @@
|
|
3
3
|
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
|
4
4
|
#include "duckdb/catalog/catalog_entry/view_catalog_entry.hpp"
|
5
5
|
#include "duckdb/main/config.hpp"
|
6
|
+
#include "duckdb/parser/parsed_expression_iterator.hpp"
|
6
7
|
#include "duckdb/parser/query_node/select_node.hpp"
|
7
8
|
#include "duckdb/parser/statement/list.hpp"
|
9
|
+
#include "duckdb/parser/tableref/joinref.hpp"
|
8
10
|
#include "duckdb/parser/tableref/table_function_ref.hpp"
|
9
11
|
#include "duckdb/planner/bound_query_node.hpp"
|
10
12
|
#include "duckdb/planner/bound_tableref.hpp"
|
@@ -13,7 +15,6 @@
|
|
13
15
|
#include "duckdb/planner/expression_iterator.hpp"
|
14
16
|
#include "duckdb/planner/operator/logical_projection.hpp"
|
15
17
|
#include "duckdb/planner/operator/logical_sample.hpp"
|
16
|
-
#include "duckdb/parser/parsed_expression_iterator.hpp"
|
17
18
|
|
18
19
|
#include <algorithm>
|
19
20
|
|
@@ -170,8 +171,12 @@ unique_ptr<BoundTableRef> Binder::Bind(TableRef &ref) {
|
|
170
171
|
case TableReferenceType::EXPRESSION_LIST:
|
171
172
|
result = Bind((ExpressionListRef &)ref);
|
172
173
|
break;
|
174
|
+
case TableReferenceType::PIVOT:
|
175
|
+
result = Bind((PivotRef &)ref);
|
176
|
+
break;
|
173
177
|
case TableReferenceType::CTE:
|
174
178
|
case TableReferenceType::INVALID:
|
179
|
+
default:
|
175
180
|
throw InternalException("Unknown table ref type");
|
176
181
|
}
|
177
182
|
result->sample = std::move(ref.sample);
|
@@ -203,6 +208,7 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundTableRef &ref) {
|
|
203
208
|
root = CreatePlan((BoundCTERef &)ref);
|
204
209
|
break;
|
205
210
|
case TableReferenceType::INVALID:
|
211
|
+
default:
|
206
212
|
throw InternalException("Unsupported bound table ref type");
|
207
213
|
}
|
208
214
|
// plan the sample clause
|
@@ -19,7 +19,7 @@ BoundOrderByNode::BoundOrderByNode(OrderType type, OrderByNullType null_order, u
|
|
19
19
|
|
20
20
|
BoundOrderByNode BoundOrderByNode::Copy() const {
|
21
21
|
if (stats) {
|
22
|
-
return BoundOrderByNode(type, null_order, expression->Copy(), stats->
|
22
|
+
return BoundOrderByNode(type, null_order, expression->Copy(), stats->ToUnique());
|
23
23
|
} else {
|
24
24
|
return BoundOrderByNode(type, null_order, expression->Copy());
|
25
25
|
}
|
@@ -102,7 +102,7 @@ unique_ptr<Expression> BoundWindowExpression::Copy() {
|
|
102
102
|
}
|
103
103
|
for (auto &ps : partitions_stats) {
|
104
104
|
if (ps) {
|
105
|
-
new_window->partitions_stats.push_back(ps->
|
105
|
+
new_window->partitions_stats.push_back(ps->ToUnique());
|
106
106
|
} else {
|
107
107
|
new_window->partitions_stats.push_back(nullptr);
|
108
108
|
}
|
@@ -1,8 +1,6 @@
|
|
1
1
|
#include "duckdb/planner/filter/constant_filter.hpp"
|
2
|
-
|
2
|
+
#include "duckdb/storage/statistics/base_statistics.hpp"
|
3
3
|
#include "duckdb/common/field_writer.hpp"
|
4
|
-
#include "duckdb/storage/statistics/numeric_statistics.hpp"
|
5
|
-
#include "duckdb/storage/statistics/string_statistics.hpp"
|
6
4
|
|
7
5
|
namespace duckdb {
|
8
6
|
|
@@ -12,7 +10,7 @@ ConstantFilter::ConstantFilter(ExpressionType comparison_type_p, Value constant_
|
|
12
10
|
}
|
13
11
|
|
14
12
|
FilterPropagateResult ConstantFilter::CheckStatistics(BaseStatistics &stats) {
|
15
|
-
D_ASSERT(constant.type().id() == stats.
|
13
|
+
D_ASSERT(constant.type().id() == stats.GetType().id());
|
16
14
|
switch (constant.type().InternalType()) {
|
17
15
|
case PhysicalType::UINT8:
|
18
16
|
case PhysicalType::UINT16:
|
@@ -25,9 +23,9 @@ FilterPropagateResult ConstantFilter::CheckStatistics(BaseStatistics &stats) {
|
|
25
23
|
case PhysicalType::INT128:
|
26
24
|
case PhysicalType::FLOAT:
|
27
25
|
case PhysicalType::DOUBLE:
|
28
|
-
return (
|
26
|
+
return NumericStats::CheckZonemap(stats, comparison_type, constant);
|
29
27
|
case PhysicalType::VARCHAR:
|
30
|
-
return (
|
28
|
+
return StringStats::CheckZonemap(stats, comparison_type, StringValue::Get(constant));
|
31
29
|
default:
|
32
30
|
return FilterPropagateResult::NO_PRUNING_POSSIBLE;
|
33
31
|
}
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
#include "duckdb/catalog/catalog.hpp"
|
6
6
|
#include "duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp"
|
7
|
-
|
7
|
+
#include "duckdb/parser/statement/multi_statement.hpp"
|
8
8
|
#include "duckdb/parser/parsed_data/pragma_info.hpp"
|
9
9
|
#include "duckdb/function/function.hpp"
|
10
10
|
|
@@ -22,6 +22,13 @@ PragmaHandler::PragmaHandler(ClientContext &context) : context(context) {
|
|
22
22
|
void PragmaHandler::HandlePragmaStatementsInternal(vector<unique_ptr<SQLStatement>> &statements) {
|
23
23
|
vector<unique_ptr<SQLStatement>> new_statements;
|
24
24
|
for (idx_t i = 0; i < statements.size(); i++) {
|
25
|
+
if (statements[i]->type == StatementType::MULTI_STATEMENT) {
|
26
|
+
auto &multi_statement = (MultiStatement &)*statements[i];
|
27
|
+
for (auto &stmt : multi_statement.statements) {
|
28
|
+
statements.push_back(std::move(stmt));
|
29
|
+
}
|
30
|
+
continue;
|
31
|
+
}
|
25
32
|
if (statements[i]->type == StatementType::PRAGMA_STATEMENT) {
|
26
33
|
// PRAGMA statement: check if we need to replace it by a new set of statements
|
27
34
|
PragmaHandler handler(context);
|
@@ -47,7 +54,8 @@ void PragmaHandler::HandlePragmaStatements(ClientContextLock &lock, vector<uniqu
|
|
47
54
|
// first check if there are any pragma statements
|
48
55
|
bool found_pragma = false;
|
49
56
|
for (idx_t i = 0; i < statements.size(); i++) {
|
50
|
-
if (statements[i]->type == StatementType::PRAGMA_STATEMENT
|
57
|
+
if (statements[i]->type == StatementType::PRAGMA_STATEMENT ||
|
58
|
+
statements[i]->type == StatementType::MULTI_STATEMENT) {
|
51
59
|
found_pragma = true;
|
52
60
|
break;
|
53
61
|
}
|
@@ -7,6 +7,7 @@
|
|
7
7
|
#include "duckdb/storage/in_memory_block_manager.hpp"
|
8
8
|
#include "duckdb/storage/storage_manager.hpp"
|
9
9
|
#include "duckdb/main/attached_database.hpp"
|
10
|
+
#include "duckdb/main/database.hpp"
|
10
11
|
|
11
12
|
namespace duckdb {
|
12
13
|
|
@@ -71,11 +72,11 @@ BlockHandle::~BlockHandle() { // NOLINT: allow internal exceptions
|
|
71
72
|
D_ASSERT(memory_charge.size > 0);
|
72
73
|
// the block is still loaded in memory: erase it
|
73
74
|
buffer.reset();
|
74
|
-
memory_charge.Resize(buffer_manager.current_memory, 0);
|
75
|
+
memory_charge.Resize(buffer_manager.buffer_pool.current_memory, 0);
|
75
76
|
} else {
|
76
77
|
D_ASSERT(memory_charge.size == 0);
|
77
78
|
}
|
78
|
-
buffer_manager.PurgeQueue();
|
79
|
+
buffer_manager.buffer_pool.PurgeQueue();
|
79
80
|
block_manager.UnregisterBlock(block_id, can_destroy);
|
80
81
|
}
|
81
82
|
|
@@ -150,7 +151,7 @@ unique_ptr<FileBuffer> BlockHandle::UnloadAndTakeBlock() {
|
|
150
151
|
// temporary block that cannot be destroyed: write to temporary file
|
151
152
|
block_manager.buffer_manager.WriteTemporaryBuffer(block_id, *buffer);
|
152
153
|
}
|
153
|
-
memory_charge.Resize(block_manager.buffer_manager.current_memory, 0);
|
154
|
+
memory_charge.Resize(block_manager.buffer_manager.buffer_pool.current_memory, 0);
|
154
155
|
state = BlockState::BLOCK_UNLOADED;
|
155
156
|
return std::move(buffer);
|
156
157
|
}
|
@@ -241,9 +242,14 @@ void BufferManager::SetTemporaryDirectory(string new_dir) {
|
|
241
242
|
this->temp_directory = std::move(new_dir);
|
242
243
|
}
|
243
244
|
|
244
|
-
|
245
|
-
:
|
246
|
-
|
245
|
+
BufferPool::BufferPool(idx_t maximum_memory)
|
246
|
+
: current_memory(0), maximum_memory(maximum_memory), queue(make_unique<EvictionQueue>()), queue_insertions(0) {
|
247
|
+
}
|
248
|
+
BufferPool::~BufferPool() {
|
249
|
+
}
|
250
|
+
|
251
|
+
BufferManager::BufferManager(DatabaseInstance &db, string tmp)
|
252
|
+
: db(db), buffer_pool(db.GetBufferPool()), temp_directory(std::move(tmp)), temporary_id(MAXIMUM_BLOCK),
|
247
253
|
buffer_allocator(BufferAllocatorAllocate, BufferAllocatorFree, BufferAllocatorRealloc,
|
248
254
|
make_unique<BufferAllocatorData>(*this)) {
|
249
255
|
temp_block_manager = make_unique<InMemoryBlockManager>(*this);
|
@@ -311,15 +317,15 @@ shared_ptr<BlockHandle> BlockManager::ConvertToPersistent(block_id_t block_id, s
|
|
311
317
|
// persist the new block to disk
|
312
318
|
Write(*new_block->buffer, block_id);
|
313
319
|
|
314
|
-
buffer_manager.AddToEvictionQueue(new_block);
|
320
|
+
buffer_manager.buffer_pool.AddToEvictionQueue(new_block);
|
315
321
|
|
316
322
|
return new_block;
|
317
323
|
}
|
318
324
|
|
319
325
|
template <typename... ARGS>
|
320
|
-
TempBufferPoolReservation BufferManager::EvictBlocksOrThrow(idx_t memory_delta,
|
321
|
-
|
322
|
-
auto r = EvictBlocks(memory_delta,
|
326
|
+
TempBufferPoolReservation BufferManager::EvictBlocksOrThrow(idx_t memory_delta, unique_ptr<FileBuffer> *buffer,
|
327
|
+
ARGS... args) {
|
328
|
+
auto r = buffer_pool.EvictBlocks(memory_delta, buffer_pool.maximum_memory, buffer);
|
323
329
|
if (!r.success) {
|
324
330
|
throw OutOfMemoryException(args..., InMemoryWarning());
|
325
331
|
}
|
@@ -328,9 +334,8 @@ TempBufferPoolReservation BufferManager::EvictBlocksOrThrow(idx_t memory_delta,
|
|
328
334
|
|
329
335
|
shared_ptr<BlockHandle> BufferManager::RegisterSmallMemory(idx_t block_size) {
|
330
336
|
D_ASSERT(block_size < Storage::BLOCK_SIZE);
|
331
|
-
auto res = EvictBlocksOrThrow(block_size,
|
332
|
-
|
333
|
-
GetUsedMemory(), GetMaxMemory());
|
337
|
+
auto res = EvictBlocksOrThrow(block_size, nullptr, "could not allocate block of %lld bytes (%lld/%lld used) %s",
|
338
|
+
block_size, GetUsedMemory(), GetMaxMemory());
|
334
339
|
|
335
340
|
auto buffer = ConstructManagedBuffer(block_size, nullptr, FileBufferType::TINY_BUFFER);
|
336
341
|
|
@@ -344,9 +349,9 @@ shared_ptr<BlockHandle> BufferManager::RegisterMemory(idx_t block_size, bool can
|
|
344
349
|
auto alloc_size = GetAllocSize(block_size);
|
345
350
|
// first evict blocks until we have enough memory to store this buffer
|
346
351
|
unique_ptr<FileBuffer> reusable_buffer;
|
347
|
-
auto res =
|
348
|
-
|
349
|
-
|
352
|
+
auto res =
|
353
|
+
EvictBlocksOrThrow(alloc_size, &reusable_buffer, "could not allocate block of %lld bytes (%lld/%lld used) %s",
|
354
|
+
alloc_size, GetUsedMemory(), GetMaxMemory());
|
350
355
|
|
351
356
|
auto buffer = ConstructManagedBuffer(block_size, std::move(reusable_buffer));
|
352
357
|
|
@@ -376,14 +381,13 @@ void BufferManager::ReAllocate(shared_ptr<BlockHandle> &handle, idx_t block_size
|
|
376
381
|
return;
|
377
382
|
} else if (memory_delta > 0) {
|
378
383
|
// evict blocks until we have space to resize this block
|
379
|
-
auto reservation =
|
380
|
-
|
381
|
-
handle->memory_usage, req.alloc_size);
|
384
|
+
auto reservation = EvictBlocksOrThrow(memory_delta, nullptr, "failed to resize block from %lld to %lld%s",
|
385
|
+
handle->memory_usage, req.alloc_size);
|
382
386
|
// EvictBlocks decrements 'current_memory' for us.
|
383
387
|
handle->memory_charge.Merge(std::move(reservation));
|
384
388
|
} else {
|
385
389
|
// no need to evict blocks, but we do need to decrement 'current_memory'.
|
386
|
-
handle->memory_charge.Resize(current_memory, req.alloc_size);
|
390
|
+
handle->memory_charge.Resize(buffer_pool.current_memory, req.alloc_size);
|
387
391
|
}
|
388
392
|
|
389
393
|
// resize and adjust current memory
|
@@ -407,15 +411,15 @@ BufferHandle BufferManager::Pin(shared_ptr<BlockHandle> &handle) {
|
|
407
411
|
}
|
408
412
|
// evict blocks until we have space for the current block
|
409
413
|
unique_ptr<FileBuffer> reusable_buffer;
|
410
|
-
auto reservation =
|
411
|
-
|
414
|
+
auto reservation =
|
415
|
+
EvictBlocksOrThrow(required_memory, &reusable_buffer, "failed to pin block of size %lld%s", required_memory);
|
412
416
|
// lock the handle again and repeat the check (in case anybody loaded in the mean time)
|
413
417
|
lock_guard<mutex> lock(handle->lock);
|
414
418
|
// check if the block is already loaded
|
415
419
|
if (handle->state == BlockState::BLOCK_LOADED) {
|
416
420
|
// the block is loaded, increment the reader count and return a pointer to the handle
|
417
421
|
handle->readers++;
|
418
|
-
reservation.Resize(current_memory, 0);
|
422
|
+
reservation.Resize(buffer_pool.current_memory, 0);
|
419
423
|
return handle->Load(handle);
|
420
424
|
}
|
421
425
|
// now we can actually load the current block
|
@@ -428,13 +432,13 @@ BufferHandle BufferManager::Pin(shared_ptr<BlockHandle> &handle) {
|
|
428
432
|
if (delta) {
|
429
433
|
D_ASSERT(delta < 0);
|
430
434
|
handle->memory_usage += delta;
|
431
|
-
handle->memory_charge.Resize(current_memory, handle->memory_usage);
|
435
|
+
handle->memory_charge.Resize(buffer_pool.current_memory, handle->memory_usage);
|
432
436
|
}
|
433
437
|
D_ASSERT(handle->memory_usage == handle->buffer->AllocSize());
|
434
438
|
return buf;
|
435
439
|
}
|
436
440
|
|
437
|
-
void
|
441
|
+
void BufferPool::AddToEvictionQueue(shared_ptr<BlockHandle> &handle) {
|
438
442
|
constexpr int INSERT_INTERVAL = 1024;
|
439
443
|
|
440
444
|
D_ASSERT(handle->readers == 0);
|
@@ -465,12 +469,12 @@ void BufferManager::Unpin(shared_ptr<BlockHandle> &handle) {
|
|
465
469
|
handle->readers--;
|
466
470
|
if (handle->readers == 0) {
|
467
471
|
VerifyZeroReaders(handle);
|
468
|
-
AddToEvictionQueue(handle);
|
472
|
+
buffer_pool.AddToEvictionQueue(handle);
|
469
473
|
}
|
470
474
|
}
|
471
475
|
|
472
|
-
|
473
|
-
|
476
|
+
BufferPool::EvictionResult BufferPool::EvictBlocks(idx_t extra_memory, idx_t memory_limit,
|
477
|
+
unique_ptr<FileBuffer> *buffer) {
|
474
478
|
BufferEvictionNode node;
|
475
479
|
TempBufferPoolReservation r(current_memory, extra_memory);
|
476
480
|
while (current_memory > memory_limit) {
|
@@ -504,7 +508,7 @@ BufferManager::EvictionResult BufferManager::EvictBlocks(idx_t extra_memory, idx
|
|
504
508
|
return {true, std::move(r)};
|
505
509
|
}
|
506
510
|
|
507
|
-
void
|
511
|
+
void BufferPool::PurgeQueue() {
|
508
512
|
BufferEvictionNode node;
|
509
513
|
while (true) {
|
510
514
|
if (!queue->q.try_dequeue(node)) {
|
@@ -531,13 +535,13 @@ void BlockManager::UnregisterBlock(block_id_t block_id, bool can_destroy) {
|
|
531
535
|
}
|
532
536
|
}
|
533
537
|
|
534
|
-
void
|
538
|
+
void BufferPool::SetLimit(idx_t limit, const char *exception_postscript) {
|
535
539
|
lock_guard<mutex> l_lock(limit_lock);
|
536
540
|
// try to evict until the limit is reached
|
537
541
|
if (!EvictBlocks(0, limit).success) {
|
538
542
|
throw OutOfMemoryException(
|
539
543
|
"Failed to change memory limit to %lld: could not free up enough memory for the new limit%s", limit,
|
540
|
-
|
544
|
+
exception_postscript);
|
541
545
|
}
|
542
546
|
idx_t old_limit = maximum_memory;
|
543
547
|
// set the global maximum memory to the new limit if successful
|
@@ -548,20 +552,16 @@ void BufferManager::SetLimit(idx_t limit) {
|
|
548
552
|
maximum_memory = old_limit;
|
549
553
|
throw OutOfMemoryException(
|
550
554
|
"Failed to change memory limit to %lld: could not free up enough memory for the new limit%s", limit,
|
551
|
-
|
555
|
+
exception_postscript);
|
552
556
|
}
|
553
557
|
}
|
554
558
|
|
555
559
|
void BufferManager::IncreaseUsedMemory(idx_t size) {
|
556
|
-
|
557
|
-
throw OutOfMemoryException("Failed to allocate data of size %lld%s", size, InMemoryWarning());
|
558
|
-
}
|
559
|
-
current_memory += size;
|
560
|
+
ReserveMemory(size);
|
560
561
|
}
|
561
562
|
|
562
563
|
void BufferManager::DecreaseUsedMemory(idx_t size) {
|
563
|
-
|
564
|
-
current_memory -= size;
|
564
|
+
FreeReservedMemory(size);
|
565
565
|
}
|
566
566
|
|
567
567
|
//===--------------------------------------------------------------------===//
|
@@ -1044,7 +1044,7 @@ vector<TemporaryFileInformation> BufferManager::GetTemporaryFiles() {
|
|
1044
1044
|
return result;
|
1045
1045
|
}
|
1046
1046
|
|
1047
|
-
|
1047
|
+
const char *BufferManager::InMemoryWarning() {
|
1048
1048
|
if (!temp_directory.empty()) {
|
1049
1049
|
return "";
|
1050
1050
|
}
|
@@ -1058,8 +1058,7 @@ void BufferManager::ReserveMemory(idx_t size) {
|
|
1058
1058
|
if (size == 0) {
|
1059
1059
|
return;
|
1060
1060
|
}
|
1061
|
-
auto reservation =
|
1062
|
-
EvictBlocksOrThrow(size, maximum_memory, nullptr, "failed to reserve memory data of size %lld%s", size);
|
1061
|
+
auto reservation = EvictBlocksOrThrow(size, nullptr, "failed to reserve memory data of size %lld%s", size);
|
1063
1062
|
reservation.size = 0;
|
1064
1063
|
}
|
1065
1064
|
|
@@ -1067,7 +1066,7 @@ void BufferManager::FreeReservedMemory(idx_t size) {
|
|
1067
1066
|
if (size == 0) {
|
1068
1067
|
return;
|
1069
1068
|
}
|
1070
|
-
current_memory -= size;
|
1069
|
+
buffer_pool.current_memory -= size;
|
1071
1070
|
}
|
1072
1071
|
|
1073
1072
|
//===--------------------------------------------------------------------===//
|
@@ -1075,8 +1074,7 @@ void BufferManager::FreeReservedMemory(idx_t size) {
|
|
1075
1074
|
//===--------------------------------------------------------------------===//
|
1076
1075
|
data_ptr_t BufferManager::BufferAllocatorAllocate(PrivateAllocatorData *private_data, idx_t size) {
|
1077
1076
|
auto &data = (BufferAllocatorData &)*private_data;
|
1078
|
-
auto reservation = data.manager.EvictBlocksOrThrow(size, data
|
1079
|
-
"failed to allocate data of size %lld%s", size);
|
1077
|
+
auto reservation = data.manager.EvictBlocksOrThrow(size, nullptr, "failed to allocate data of size %lld%s", size);
|
1080
1078
|
// We rely on manual tracking of this one. :(
|
1081
1079
|
reservation.size = 0;
|
1082
1080
|
return Allocator::Get(data.manager.db).AllocateData(size);
|
@@ -1086,7 +1084,7 @@ void BufferManager::BufferAllocatorFree(PrivateAllocatorData *private_data, data
|
|
1086
1084
|
auto &data = (BufferAllocatorData &)*private_data;
|
1087
1085
|
BufferPoolReservation r;
|
1088
1086
|
r.size = size;
|
1089
|
-
r.Resize(data.manager.current_memory, 0);
|
1087
|
+
r.Resize(data.manager.buffer_pool.current_memory, 0);
|
1090
1088
|
return Allocator::Get(data.manager.db).FreeData(pointer, size);
|
1091
1089
|
}
|
1092
1090
|
|
@@ -1098,7 +1096,7 @@ data_ptr_t BufferManager::BufferAllocatorRealloc(PrivateAllocatorData *private_d
|
|
1098
1096
|
auto &data = (BufferAllocatorData &)*private_data;
|
1099
1097
|
BufferPoolReservation r;
|
1100
1098
|
r.size = old_size;
|
1101
|
-
r.Resize(data.manager.current_memory, size);
|
1099
|
+
r.Resize(data.manager.buffer_pool.current_memory, size);
|
1102
1100
|
r.size = 0;
|
1103
1101
|
return Allocator::Get(data.manager.db).ReallocateData(pointer, old_size, size);
|
1104
1102
|
}
|
@@ -32,7 +32,7 @@ void SingleFileRowGroupWriter::WriteColumnDataPointers(ColumnCheckpointState &co
|
|
32
32
|
meta_writer.Write<block_id_t>(data_pointer.block_pointer.block_id);
|
33
33
|
meta_writer.Write<uint32_t>(data_pointer.block_pointer.offset);
|
34
34
|
meta_writer.Write<CompressionType>(data_pointer.compression_type);
|
35
|
-
data_pointer.statistics
|
35
|
+
data_pointer.statistics.Serialize(meta_writer);
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
@@ -24,10 +24,7 @@ void TableDataReader::ReadTableData() {
|
|
24
24
|
D_ASSERT(!columns.empty());
|
25
25
|
|
26
26
|
// deserialize the total table statistics
|
27
|
-
info.data->
|
28
|
-
for (auto &col : columns.Physical()) {
|
29
|
-
info.data->column_stats.push_back(BaseStatistics::Deserialize(reader, col.Type()));
|
30
|
-
}
|
27
|
+
info.data->table_stats.Deserialize(reader, columns);
|
31
28
|
|
32
29
|
// deserialize each of the individual row groups
|
33
30
|
auto row_group_count = reader.Read<uint64_t>();
|
@@ -5,6 +5,7 @@
|
|
5
5
|
#include "duckdb/common/vector_operations/vector_operations.hpp"
|
6
6
|
#include "duckdb/common/serializer/buffered_serializer.hpp"
|
7
7
|
#include "duckdb/storage/table/column_checkpoint_state.hpp"
|
8
|
+
#include "duckdb/storage/table/table_statistics.hpp"
|
8
9
|
|
9
10
|
namespace duckdb {
|
10
11
|
|
@@ -40,14 +41,13 @@ unique_ptr<RowGroupWriter> SingleFileTableDataWriter::GetRowGroupWriter(RowGroup
|
|
40
41
|
return make_unique<SingleFileRowGroupWriter>(table, checkpoint_manager.partial_block_manager, table_data_writer);
|
41
42
|
}
|
42
43
|
|
43
|
-
void SingleFileTableDataWriter::FinalizeTable(
|
44
|
+
void SingleFileTableDataWriter::FinalizeTable(TableStatistics &&global_stats, DataTableInfo *info) {
|
44
45
|
// store the current position in the metadata writer
|
45
46
|
// this is where the row groups for this table start
|
46
47
|
auto pointer = table_data_writer.GetBlockPointer();
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
}
|
49
|
+
global_stats.Serialize(table_data_writer);
|
50
|
+
|
51
51
|
// now start writing the row group pointers to disk
|
52
52
|
table_data_writer.Write<uint64_t>(row_group_pointers.size());
|
53
53
|
for (auto &row_group_pointer : row_group_pointers) {
|
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "duckdb/function/compression_function.hpp"
|
7
7
|
#include "duckdb/main/config.hpp"
|
8
8
|
#include "duckdb/storage/buffer_manager.hpp"
|
9
|
-
|
9
|
+
|
10
10
|
#include "duckdb/storage/table/column_data_checkpointer.hpp"
|
11
11
|
#include "duckdb/storage/table/column_segment.hpp"
|
12
12
|
#include "duckdb/common/operator/subtract.hpp"
|
@@ -347,7 +347,7 @@ idx_t BitpackingFinalAnalyze(AnalyzeState &state) {
|
|
347
347
|
//===--------------------------------------------------------------------===//
|
348
348
|
// Compress
|
349
349
|
//===--------------------------------------------------------------------===//
|
350
|
-
template <class T, class T_S = typename std::make_signed<T>::type>
|
350
|
+
template <class T, bool WRITE_STATISTICS, class T_S = typename std::make_signed<T>::type>
|
351
351
|
struct BitpackingCompressState : public CompressionState {
|
352
352
|
public:
|
353
353
|
explicit BitpackingCompressState(ColumnDataCheckpointer &checkpointer) : checkpointer(checkpointer) {
|
@@ -377,7 +377,7 @@ public:
|
|
377
377
|
public:
|
378
378
|
struct BitpackingWriter {
|
379
379
|
static void WriteConstant(T constant, idx_t count, void *data_ptr, bool all_invalid) {
|
380
|
-
auto state = (BitpackingCompressState<T> *)data_ptr;
|
380
|
+
auto state = (BitpackingCompressState<T, WRITE_STATISTICS> *)data_ptr;
|
381
381
|
|
382
382
|
ReserveSpace(state, sizeof(T));
|
383
383
|
WriteMetaData(state, BitpackingMode::CONSTANT);
|
@@ -388,7 +388,7 @@ public:
|
|
388
388
|
|
389
389
|
static void WriteConstantDelta(T_S constant, T frame_of_reference, idx_t count, T *values, bool *validity,
|
390
390
|
void *data_ptr) {
|
391
|
-
auto state = (BitpackingCompressState<T> *)data_ptr;
|
391
|
+
auto state = (BitpackingCompressState<T, WRITE_STATISTICS> *)data_ptr;
|
392
392
|
|
393
393
|
ReserveSpace(state, 2 * sizeof(T));
|
394
394
|
WriteMetaData(state, BitpackingMode::CONSTANT_DELTA);
|
@@ -400,7 +400,7 @@ public:
|
|
400
400
|
|
401
401
|
static void WriteDeltaFor(T *values, bool *validity, bitpacking_width_t width, T frame_of_reference,
|
402
402
|
T_S delta_offset, T *original_values, idx_t count, void *data_ptr) {
|
403
|
-
auto state = (BitpackingCompressState<T> *)data_ptr;
|
403
|
+
auto state = (BitpackingCompressState<T, WRITE_STATISTICS> *)data_ptr;
|
404
404
|
|
405
405
|
auto bp_size = BitpackingPrimitives::GetRequiredSize(count, width);
|
406
406
|
ReserveSpace(state, bp_size + 3 * sizeof(T));
|
@@ -418,7 +418,7 @@ public:
|
|
418
418
|
|
419
419
|
static void WriteFor(T *values, bool *validity, bitpacking_width_t width, T frame_of_reference, idx_t count,
|
420
420
|
void *data_ptr) {
|
421
|
-
auto state = (BitpackingCompressState<T> *)data_ptr;
|
421
|
+
auto state = (BitpackingCompressState<T, WRITE_STATISTICS> *)data_ptr;
|
422
422
|
|
423
423
|
auto bp_size = BitpackingPrimitives::GetRequiredSize(count, width);
|
424
424
|
ReserveSpace(state, bp_size + 2 * sizeof(T));
|
@@ -439,24 +439,24 @@ public:
|
|
439
439
|
ptr += sizeof(T_OUT);
|
440
440
|
}
|
441
441
|
|
442
|
-
static void WriteMetaData(BitpackingCompressState<T> *state, BitpackingMode mode) {
|
442
|
+
static void WriteMetaData(BitpackingCompressState<T, WRITE_STATISTICS> *state, BitpackingMode mode) {
|
443
443
|
bitpacking_metadata_t metadata {mode, (uint32_t)(state->data_ptr - state->handle.Ptr())};
|
444
444
|
state->metadata_ptr -= sizeof(bitpacking_metadata_encoded_t);
|
445
445
|
Store<bitpacking_metadata_encoded_t>(EncodeMeta(metadata), state->metadata_ptr);
|
446
446
|
}
|
447
447
|
|
448
|
-
static void ReserveSpace(BitpackingCompressState<T> *state, idx_t data_bytes) {
|
448
|
+
static void ReserveSpace(BitpackingCompressState<T, WRITE_STATISTICS> *state, idx_t data_bytes) {
|
449
449
|
idx_t meta_bytes = sizeof(bitpacking_metadata_encoded_t);
|
450
450
|
state->FlushAndCreateSegmentIfFull(data_bytes, meta_bytes);
|
451
451
|
D_ASSERT(state->CanStore(data_bytes, meta_bytes));
|
452
452
|
}
|
453
453
|
|
454
|
-
static void UpdateStats(BitpackingCompressState<T> *state, idx_t count) {
|
454
|
+
static void UpdateStats(BitpackingCompressState<T, WRITE_STATISTICS> *state, idx_t count) {
|
455
455
|
state->current_segment->count += count;
|
456
456
|
|
457
|
-
if (!state->state.all_invalid) {
|
458
|
-
|
459
|
-
|
457
|
+
if (WRITE_STATISTICS && !state->state.all_invalid) {
|
458
|
+
NumericStats::Update<T>(state->current_segment->stats.statistics, state->state.minimum);
|
459
|
+
NumericStats::Update<T>(state->current_segment->stats.statistics, state->state.maximum);
|
460
460
|
}
|
461
461
|
}
|
462
462
|
};
|
@@ -487,8 +487,8 @@ public:
|
|
487
487
|
|
488
488
|
for (idx_t i = 0; i < count; i++) {
|
489
489
|
auto idx = vdata.sel->get_index(i);
|
490
|
-
state.template Update<BitpackingCompressState<T, T_S>::BitpackingWriter>(
|
491
|
-
|
490
|
+
state.template Update<BitpackingCompressState<T, WRITE_STATISTICS, T_S>::BitpackingWriter>(
|
491
|
+
data[idx], vdata.validity.RowIsValid(idx));
|
492
492
|
}
|
493
493
|
}
|
494
494
|
|
@@ -524,29 +524,29 @@ public:
|
|
524
524
|
}
|
525
525
|
|
526
526
|
void Finalize() {
|
527
|
-
state.template Flush<BitpackingCompressState<T, T_S>::BitpackingWriter>();
|
527
|
+
state.template Flush<BitpackingCompressState<T, WRITE_STATISTICS, T_S>::BitpackingWriter>();
|
528
528
|
FlushSegment();
|
529
529
|
current_segment.reset();
|
530
530
|
}
|
531
531
|
};
|
532
532
|
|
533
|
-
template <class T>
|
533
|
+
template <class T, bool WRITE_STATISTICS>
|
534
534
|
unique_ptr<CompressionState> BitpackingInitCompression(ColumnDataCheckpointer &checkpointer,
|
535
535
|
unique_ptr<AnalyzeState> state) {
|
536
|
-
return make_unique<BitpackingCompressState<T>>(checkpointer);
|
536
|
+
return make_unique<BitpackingCompressState<T, WRITE_STATISTICS>>(checkpointer);
|
537
537
|
}
|
538
538
|
|
539
|
-
template <class T>
|
539
|
+
template <class T, bool WRITE_STATISTICS>
|
540
540
|
void BitpackingCompress(CompressionState &state_p, Vector &scan_vector, idx_t count) {
|
541
|
-
auto &state = (BitpackingCompressState<T> &)state_p;
|
541
|
+
auto &state = (BitpackingCompressState<T, WRITE_STATISTICS> &)state_p;
|
542
542
|
UnifiedVectorFormat vdata;
|
543
543
|
scan_vector.ToUnifiedFormat(count, vdata);
|
544
544
|
state.Append(vdata, count);
|
545
545
|
}
|
546
546
|
|
547
|
-
template <class T>
|
547
|
+
template <class T, bool WRITE_STATISTICS>
|
548
548
|
void BitpackingFinalizeCompress(CompressionState &state_p) {
|
549
|
-
auto &state = (BitpackingCompressState<T> &)state_p;
|
549
|
+
auto &state = (BitpackingCompressState<T, WRITE_STATISTICS> &)state_p;
|
550
550
|
state.Finalize();
|
551
551
|
}
|
552
552
|
|
@@ -880,11 +880,12 @@ void BitpackingSkip(ColumnSegment &segment, ColumnScanState &state, idx_t skip_c
|
|
880
880
|
//===--------------------------------------------------------------------===//
|
881
881
|
// Get Function
|
882
882
|
//===--------------------------------------------------------------------===//
|
883
|
-
template <class T>
|
883
|
+
template <class T, bool WRITE_STATISTICS = true>
|
884
884
|
CompressionFunction GetBitpackingFunction(PhysicalType data_type) {
|
885
885
|
return CompressionFunction(CompressionType::COMPRESSION_BITPACKING, data_type, BitpackingInitAnalyze<T>,
|
886
|
-
BitpackingAnalyze<T>, BitpackingFinalAnalyze<T>,
|
887
|
-
|
886
|
+
BitpackingAnalyze<T>, BitpackingFinalAnalyze<T>,
|
887
|
+
BitpackingInitCompression<T, WRITE_STATISTICS>, BitpackingCompress<T, WRITE_STATISTICS>,
|
888
|
+
BitpackingFinalizeCompress<T, WRITE_STATISTICS>, BitpackingInitScan<T>,
|
888
889
|
BitpackingScan<T>, BitpackingScanPartial<T>, BitpackingFetchRow<T>, BitpackingSkip<T>);
|
889
890
|
}
|
890
891
|
|
@@ -907,6 +908,8 @@ CompressionFunction BitpackingFun::GetFunction(PhysicalType type) {
|
|
907
908
|
return GetBitpackingFunction<uint32_t>(type);
|
908
909
|
case PhysicalType::UINT64:
|
909
910
|
return GetBitpackingFunction<uint64_t>(type);
|
911
|
+
case PhysicalType::LIST:
|
912
|
+
return GetBitpackingFunction<uint64_t, false>(type);
|
910
913
|
default:
|
911
914
|
throw InternalException("Unsupported type for Bitpacking");
|
912
915
|
}
|
@@ -923,6 +926,7 @@ bool BitpackingFun::TypeIsSupported(PhysicalType type) {
|
|
923
926
|
case PhysicalType::UINT16:
|
924
927
|
case PhysicalType::UINT32:
|
925
928
|
case PhysicalType::UINT64:
|
929
|
+
case PhysicalType::LIST:
|
926
930
|
return true;
|
927
931
|
default:
|
928
932
|
return false;
|