duckdb 0.7.2-dev2507.0 → 0.7.2-dev2675.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.
Files changed (254) hide show
  1. package/binding.gyp +7 -7
  2. package/package.json +2 -2
  3. package/src/connection.cpp +1 -1
  4. package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
  5. package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
  6. package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
  7. package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
  8. package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
  9. package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
  10. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  11. package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
  12. package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
  13. package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
  14. package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
  15. package/src/duckdb/extension/json/json-extension.cpp +6 -6
  16. package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
  17. package/src/duckdb/extension/parquet/parquet_statistics.cpp +3 -0
  18. package/src/duckdb/src/catalog/catalog.cpp +166 -127
  19. package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
  20. package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
  21. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
  22. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
  23. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
  24. package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
  25. package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
  26. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
  27. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
  28. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
  29. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
  30. package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
  31. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
  32. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
  33. package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
  34. package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
  35. package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
  36. package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
  37. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
  38. package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
  39. package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
  40. package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
  41. package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
  42. package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
  43. package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
  44. package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
  45. package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
  46. package/src/duckdb/src/common/types.cpp +15 -27
  47. package/src/duckdb/src/execution/index/art/art.cpp +286 -269
  48. package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
  49. package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
  50. package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
  51. package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
  52. package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
  53. package/src/duckdb/src/execution/index/art/node.cpp +444 -379
  54. package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
  55. package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
  56. package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
  57. package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
  58. package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
  59. package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
  60. package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
  61. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -3
  62. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
  63. package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
  64. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
  65. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
  66. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
  67. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  68. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
  69. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +17 -17
  70. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
  71. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
  72. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  73. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
  74. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
  75. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
  76. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
  77. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
  78. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  79. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
  80. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  81. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  82. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  83. package/src/duckdb/src/function/built_in_functions.cpp +10 -10
  84. package/src/duckdb/src/function/function_binder.cpp +3 -3
  85. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
  86. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
  87. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
  88. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
  89. package/src/duckdb/src/function/table/arrow.cpp +5 -5
  90. package/src/duckdb/src/function/table/read_csv.cpp +5 -1
  91. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
  92. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
  93. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
  94. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
  95. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
  96. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
  97. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
  98. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
  99. package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
  100. package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
  101. package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
  102. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
  103. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
  104. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
  105. package/src/duckdb/src/function/table/table_scan.cpp +39 -37
  106. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  107. package/src/duckdb/src/function/udf_function.cpp +2 -2
  108. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
  109. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
  110. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
  111. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
  112. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
  113. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
  114. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
  115. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
  117. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
  118. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
  119. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
  120. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
  121. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
  123. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
  124. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
  125. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
  126. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
  127. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
  128. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
  129. package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
  130. package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
  131. package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
  132. package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
  133. package/src/duckdb/src/include/duckdb/common/queue.hpp +1 -1
  134. package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
  135. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
  136. package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
  137. package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
  138. package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
  139. package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
  140. package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
  141. package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
  142. package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
  143. package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
  144. package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
  145. package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
  146. package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
  147. package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
  148. package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
  149. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
  150. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
  151. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
  152. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
  153. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
  154. package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
  155. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
  156. package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
  157. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
  158. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
  159. package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
  160. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
  161. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
  162. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
  163. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
  164. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
  165. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
  166. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
  167. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +4 -1
  168. package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
  169. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +4 -1
  170. package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
  171. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
  172. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
  173. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
  174. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +0 -5
  175. package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
  176. package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
  177. package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
  178. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
  179. package/src/duckdb/src/include/duckdb.h +26 -0
  180. package/src/duckdb/src/main/attached_database.cpp +12 -6
  181. package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
  182. package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
  183. package/src/duckdb/src/main/client_context.cpp +12 -11
  184. package/src/duckdb/src/main/database_manager.cpp +13 -12
  185. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
  186. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
  187. package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
  188. package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
  189. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
  190. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
  191. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
  192. package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
  193. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
  194. package/src/duckdb/src/parser/statement/insert_statement.cpp +15 -6
  195. package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
  196. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
  197. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
  198. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
  199. package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
  200. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
  201. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +5 -7
  202. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
  203. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
  204. package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
  205. package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
  206. package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
  207. package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
  208. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
  209. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
  210. package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
  211. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
  212. package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
  213. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
  214. package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
  215. package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
  216. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
  217. package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
  218. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
  219. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +56 -42
  220. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
  221. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  222. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
  223. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
  224. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +16 -11
  225. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
  226. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
  227. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  228. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
  229. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
  230. package/src/duckdb/src/planner/binder.cpp +2 -2
  231. package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
  232. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
  233. package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
  234. package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
  235. package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
  236. package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
  237. package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
  238. package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
  239. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
  240. package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
  241. package/src/duckdb/src/storage/checkpoint_manager.cpp +57 -55
  242. package/src/duckdb/src/storage/data_table.cpp +9 -9
  243. package/src/duckdb/src/storage/index.cpp +18 -6
  244. package/src/duckdb/src/storage/local_storage.cpp +8 -2
  245. package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
  246. package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
  247. package/src/duckdb/src/storage/wal_replay.cpp +29 -31
  248. package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
  249. package/src/duckdb/src/transaction/cleanup_state.cpp +7 -1
  250. package/src/duckdb/src/transaction/commit_state.cpp +3 -4
  251. package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
  252. package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
  253. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
  254. package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -7,50 +7,62 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
 
9
9
  #pragma once
10
+
11
+ #include "duckdb/execution/index/art/art.hpp"
12
+ #include "duckdb/execution/index/art/fixed_size_allocator.hpp"
10
13
  #include "duckdb/execution/index/art/node.hpp"
11
- #include "duckdb/execution/index/art/swizzleable_pointer.hpp"
14
+ #include "duckdb/execution/index/art/prefix.hpp"
12
15
 
13
16
  namespace duckdb {
14
17
 
15
- class Node16 : public Node {
18
+ //! Node16 holds up to 16 ARTNode children sorted by their key byte
19
+ class Node16 {
16
20
  public:
17
- //! Empty Node16
18
- explicit Node16();
21
+ //! Number of non-null children
22
+ uint8_t count;
23
+ //! Compressed path (prefix)
24
+ Prefix prefix;
19
25
  //! Array containing all partial key bytes
20
- uint8_t key[16];
21
- //! ART pointers to the child nodes
22
- ARTPointer children[16];
26
+ uint8_t key[Node::NODE_16_CAPACITY];
27
+ //! ART node pointers to the child nodes
28
+ Node children[Node::NODE_16_CAPACITY];
23
29
 
24
30
  public:
25
- static Node16 *New();
26
- //! Returns the memory size of the Node16
27
- idx_t MemorySize(ART &art, const bool &recurse) override;
28
- //! Get position of a specific byte, returns DConstants::INVALID_INDEX if not exists
29
- idx_t GetChildPos(uint8_t k) override;
30
- //! Get the position of the first child that is greater or equal to the specific byte, or DConstants::INVALID_INDEX
31
- //! if there are no children matching the criteria
32
- idx_t GetChildGreaterEqual(uint8_t k, bool &equal) override;
33
- //! Get the position of the minimum element in the node
34
- idx_t GetMin() override;
35
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
36
- idx_t GetNextPos(idx_t pos) override;
37
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
38
- idx_t GetNextPosAndByte(idx_t pos, uint8_t &byte) override;
39
- //! Get Node16 child
40
- Node *GetChild(ART &art, idx_t pos) override;
41
- //! Replace child pointer
42
- void ReplaceChildPointer(idx_t pos, Node *node) override;
43
- //! Returns whether the child at pos is in memory
44
- bool ChildIsInMemory(idx_t pos) override;
45
-
46
- //! Insert a new child node at key_byte into the Node16
47
- static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
48
- //! Erase the child at pos and (if necessary) shrink to Node4
49
- static void EraseChild(ART &art, Node *&node, idx_t pos);
50
-
51
- //! Returns the size (maximum capacity) of the Node16
52
- static constexpr idx_t GetSize() {
53
- return 16;
31
+ //! Get a new Node16 node, might cause a new buffer allocation, and initialize it
32
+ static Node16 &New(ART &art, Node &node);
33
+ //! Free the node (and its subtree)
34
+ static void Free(ART &art, Node &node);
35
+ //! Get a reference to the node
36
+ static inline Node16 &Get(const ART &art, const Node ptr) {
37
+ return *Node::GetAllocator(art, NType::NODE_16).Get<Node16>(ptr);
54
38
  }
39
+ //! Initializes all the fields of the node while growing a Node4 to a Node16
40
+ static Node16 &GrowNode4(ART &art, Node &node16, Node &node4);
41
+ //! Initializes all fields of the node while shrinking a Node48 to a Node16
42
+ static Node16 &ShrinkNode48(ART &art, Node &node16, Node &node48);
43
+
44
+ //! Initializes a merge by incrementing the buffer IDs of the node
45
+ void InitializeMerge(ART &art, const ARTFlags &flags);
46
+
47
+ //! Insert a child node at byte
48
+ static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
49
+ //! Delete the child node at the respective byte
50
+ static void DeleteChild(ART &art, Node &node, const uint8_t byte);
51
+
52
+ //! Replace the child node at the respective byte
53
+ void ReplaceChild(const uint8_t byte, const Node child);
54
+
55
+ //! Get the child for the respective byte in the node
56
+ optional_ptr<Node> GetChild(const uint8_t byte);
57
+ //! Get the first child that is greater or equal to the specific byte
58
+ optional_ptr<Node> GetNextChild(uint8_t &byte);
59
+
60
+ //! Serialize an ART node
61
+ BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
62
+ //! Deserialize this node
63
+ void Deserialize(ART &art, MetaBlockReader &reader);
64
+
65
+ //! Vacuum the children of the node
66
+ void Vacuum(ART &art, const ARTFlags &flags);
55
67
  };
56
68
  } // namespace duckdb
@@ -7,48 +7,65 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
 
9
9
  #pragma once
10
+
11
+ #include "duckdb/execution/index/art/art.hpp"
12
+ #include "duckdb/execution/index/art/fixed_size_allocator.hpp"
10
13
  #include "duckdb/execution/index/art/node.hpp"
11
- #include "duckdb/execution/index/art/swizzleable_pointer.hpp"
14
+ #include "duckdb/execution/index/art/prefix.hpp"
12
15
 
13
16
  namespace duckdb {
14
17
 
15
- class Node256 : public Node {
18
+ //! Node256 holds up to 256 ARTNode children which can be directly indexed by the key byte
19
+ class Node256 {
16
20
  public:
17
- //! Empty Node256
18
- explicit Node256();
19
- //! ART pointers to the child nodes
20
- ARTPointer children[256];
21
+ //! Number of non-null children
22
+ uint16_t count;
23
+ //! Compressed path (prefix)
24
+ Prefix prefix;
25
+ //! ART node pointers to the child nodes
26
+ Node children[Node::NODE_256_CAPACITY];
21
27
 
22
28
  public:
23
- static Node256 *New();
24
- //! Returns the memory size of the Node256
25
- idx_t MemorySize(ART &art, const bool &recurse) override;
26
- //! Get position of a specific byte, returns DConstants::INVALID_INDEX if not exists
27
- idx_t GetChildPos(uint8_t k) override;
28
- //! Get the position of the first child that is greater or equal to the specific byte, or DConstants::INVALID_INDEX
29
- //! if there are no children matching the criteria
30
- idx_t GetChildGreaterEqual(uint8_t k, bool &equal) override;
31
- //! Get the position of the minimum element in the node
32
- idx_t GetMin() override;
33
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
34
- idx_t GetNextPos(idx_t pos) override;
35
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
36
- idx_t GetNextPosAndByte(idx_t pos, uint8_t &byte) override;
37
- //! Get Node256 child
38
- Node *GetChild(ART &art, idx_t pos) override;
39
- //! Replace child pointer
40
- void ReplaceChildPointer(idx_t pos, Node *node) override;
41
- //! Returns whether the child at pos is in memory
42
- bool ChildIsInMemory(idx_t pos) override;
43
-
44
- //! Insert a new child node at key_byte into the Node256
45
- static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
46
- //! Erase the child at pos and (if necessary) shrink to Node48
47
- static void EraseChild(ART &art, Node *&node, idx_t pos);
48
-
49
- //! Returns the size (maximum capacity) of the Node256
50
- static constexpr idx_t GetSize() {
51
- return 256;
29
+ //! Get a new Node256 node, might cause a new buffer allocation, and initialize it
30
+ static Node256 &New(ART &art, Node &node);
31
+ //! Free the node (and its subtree)
32
+ static void Free(ART &art, Node &node);
33
+ //! Get a reference to the node
34
+ static inline Node256 &Get(const ART &art, const Node ptr) {
35
+ return *Node::GetAllocator(art, NType::NODE_256).Get<Node256>(ptr);
36
+ }
37
+ //! Initializes all the fields of the node while growing a Node48 to a Node256
38
+ static Node256 &GrowNode48(ART &art, Node &node256, Node &node48);
39
+
40
+ //! Initializes a merge by incrementing the buffer IDs of the node
41
+ void InitializeMerge(ART &art, const ARTFlags &flags);
42
+
43
+ //! Insert a child node at byte
44
+ static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
45
+ //! Delete the child node at the respective byte
46
+ static void DeleteChild(ART &art, Node &node, const uint8_t byte);
47
+
48
+ //! Replace the child node at the respective byte
49
+ inline void ReplaceChild(const uint8_t byte, const Node child) {
50
+ children[byte] = child;
52
51
  }
52
+
53
+ //! Get the child for the respective byte in the node
54
+ inline optional_ptr<Node> GetChild(const uint8_t byte) {
55
+ if (children[byte].IsSet()) {
56
+ return &children[byte];
57
+ }
58
+ return nullptr;
59
+ }
60
+ //! Get the first child that is greater or equal to the specific byte
61
+ optional_ptr<Node> GetNextChild(uint8_t &byte);
62
+
63
+ //! Serialize an ART node
64
+ BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
65
+ //! Deserialize this node
66
+ void Deserialize(ART &art, MetaBlockReader &reader);
67
+
68
+ //! Vacuum the children of the node
69
+ void Vacuum(ART &art, const ARTFlags &flags);
53
70
  };
54
71
  } // namespace duckdb
@@ -7,50 +7,60 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
 
9
9
  #pragma once
10
+
11
+ #include "duckdb/execution/index/art/art.hpp"
12
+ #include "duckdb/execution/index/art/fixed_size_allocator.hpp"
10
13
  #include "duckdb/execution/index/art/node.hpp"
11
- #include "duckdb/execution/index/art/swizzleable_pointer.hpp"
14
+ #include "duckdb/execution/index/art/prefix.hpp"
12
15
 
13
16
  namespace duckdb {
14
17
 
15
- class Node4 : public Node {
18
+ //! Node4 holds up to four ARTNode children sorted by their key byte
19
+ class Node4 {
16
20
  public:
17
- //! Empty Node4
18
- explicit Node4();
21
+ //! Number of non-null children
22
+ uint8_t count;
23
+ //! Compressed path (prefix)
24
+ Prefix prefix;
19
25
  //! Array containing all partial key bytes
20
- uint8_t key[4];
21
- //! ART pointers to the child nodes
22
- ARTPointer children[4];
26
+ uint8_t key[Node::NODE_4_CAPACITY];
27
+ //! ART node pointers to the child nodes
28
+ Node children[Node::NODE_4_CAPACITY];
23
29
 
24
30
  public:
25
- static Node4 *New();
26
- //! Returns the memory size of the Node4
27
- idx_t MemorySize(ART &art, const bool &recurse) override;
28
- //! Get position of a byte, returns DConstants::INVALID_INDEX if not exists
29
- idx_t GetChildPos(uint8_t k) override;
30
- //! Get the position of the first child that is greater or equal to the specific byte, or DConstants::INVALID_INDEX
31
- //! if there are no children matching the criteria
32
- idx_t GetChildGreaterEqual(uint8_t k, bool &equal) override;
33
- //! Get the position of the minimum element in the node
34
- idx_t GetMin() override;
35
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
36
- idx_t GetNextPos(idx_t pos) override;
37
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
38
- idx_t GetNextPosAndByte(idx_t pos, uint8_t &byte) override;
39
- //! Get Node4 child
40
- Node *GetChild(ART &art, idx_t pos) override;
41
- //! Replace child pointer
42
- void ReplaceChildPointer(idx_t pos, Node *node) override;
43
- //! Returns whether the child at pos is in memory
44
- bool ChildIsInMemory(idx_t pos) override;
45
-
46
- //! Insert a new child node at key_byte into the Node4
47
- static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
48
- //! Erase the child at pos and (if necessary) merge with last child
49
- static void EraseChild(ART &art, Node *&node, idx_t pos);
50
-
51
- //! Returns the size (maximum capacity) of the Node4
52
- static constexpr idx_t GetSize() {
53
- return 4;
31
+ //! Get a new Node4 node, might cause a new buffer allocation, and initialize it
32
+ static Node4 &New(ART &art, Node &node);
33
+ //! Free the node (and its subtree)
34
+ static void Free(ART &art, Node &node);
35
+ //! Get a reference to the node
36
+ static inline Node4 &Get(const ART &art, const Node ptr) {
37
+ return *Node::GetAllocator(art, NType::NODE_4).Get<Node4>(ptr);
54
38
  }
39
+ //! Initializes all fields of the node while shrinking a Node16 to a Node4
40
+ static Node4 &ShrinkNode16(ART &art, Node &node4, Node &node16);
41
+
42
+ //! Initializes a merge by incrementing the buffer IDs of the node
43
+ void InitializeMerge(ART &art, const ARTFlags &flags);
44
+
45
+ //! Insert a child node at byte
46
+ static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
47
+ //! Delete the child node at the respective byte
48
+ static void DeleteChild(ART &art, Node &node, const uint8_t byte);
49
+
50
+ //! Replace the child node at the respective byte
51
+ void ReplaceChild(const uint8_t byte, const Node child);
52
+
53
+ //! Get the child for the respective byte in the node
54
+ optional_ptr<Node> GetChild(const uint8_t byte);
55
+ //! Get the first child that is greater or equal to the specific byte
56
+ optional_ptr<Node> GetNextChild(uint8_t &byte);
57
+
58
+ //! Serialize an ART node
59
+ BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
60
+ //! Deserialize this node
61
+ void Deserialize(ART &art, MetaBlockReader &reader);
62
+
63
+ //! Vacuum the children of the node
64
+ void Vacuum(ART &art, const ARTFlags &flags);
55
65
  };
56
66
  } // namespace duckdb
@@ -7,49 +7,71 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
 
9
9
  #pragma once
10
+
11
+ #include "duckdb/execution/index/art/art.hpp"
12
+ #include "duckdb/execution/index/art/fixed_size_allocator.hpp"
10
13
  #include "duckdb/execution/index/art/node.hpp"
11
- #include "duckdb/execution/index/art/swizzleable_pointer.hpp"
14
+ #include "duckdb/execution/index/art/prefix.hpp"
12
15
 
13
16
  namespace duckdb {
14
17
 
15
- class Node48 : public Node {
18
+ //! Node48 holds up to 48 ARTNode children. It contains a child_index array which can be directly indexed by the key
19
+ //! byte, and which contains the position of the child node in the children array
20
+ class Node48 {
16
21
  public:
17
- //! Empty Node48
18
- explicit Node48();
22
+ //! Number of non-null children
23
+ uint8_t count;
24
+ //! Compressed path (prefix)
25
+ Prefix prefix;
19
26
  //! Array containing all possible partial key bytes, those not set have an EMPTY_MARKER
20
- uint8_t child_index[256];
21
- //! ART pointers to the child nodes
22
- ARTPointer children[48];
27
+ uint8_t child_index[Node::NODE_256_CAPACITY];
28
+ //! ART node pointers to the child nodes
29
+ Node children[Node::NODE_48_CAPACITY];
23
30
 
24
31
  public:
25
- static Node48 *New();
26
- //! Returns the memory size of the Node48
27
- idx_t MemorySize(ART &art, const bool &recurse) override;
28
- //! Get position of a specific byte, returns DConstants::INVALID_INDEX if not exists
29
- idx_t GetChildPos(uint8_t k) override;
30
- //! Get the position of the first child that is greater or equal to the specific byte, or DConstants::INVALID_INDEX
31
- //! if there are no children matching the criteria
32
- idx_t GetChildGreaterEqual(uint8_t k, bool &equal) override;
33
- //! Get the position of the minimum element in the node
34
- idx_t GetMin() override;
35
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
36
- idx_t GetNextPos(idx_t pos) override;
37
- //! Get the next position in the node, or DConstants::INVALID_INDEX if there is no next position
38
- idx_t GetNextPosAndByte(idx_t pos, uint8_t &byte) override;
39
- //! Get Node48 child
40
- Node *GetChild(ART &art, idx_t pos) override;
41
- //! Replace child pointer
42
- void ReplaceChildPointer(idx_t pos, Node *node) override;
43
- //! Returns whether the child at pos is in memory
44
- bool ChildIsInMemory(idx_t pos) override;
45
-
46
- //! Insert a new child node at key_byte into the Node48
47
- static void InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child);
48
- //! Erase the child at pos and (if necessary) shrink to Node16
49
- static void EraseChild(ART &art, Node *&node, idx_t pos);
50
- //! Returns the size (maximum capacity) of the Node48
51
- static constexpr idx_t GetSize() {
52
- return 48;
32
+ //! Get a new Node48 node, might cause a new buffer allocation, and initialize it
33
+ static Node48 &New(ART &art, Node &node);
34
+ //! Free the node (and its subtree)
35
+ static void Free(ART &art, Node &node);
36
+ //! Get a reference to the node
37
+ static inline Node48 &Get(const ART &art, const Node ptr) {
38
+ return *Node::GetAllocator(art, NType::NODE_48).Get<Node48>(ptr);
39
+ }
40
+ //! Initializes all the fields of the node while growing a Node16 to a Node48
41
+ static Node48 &GrowNode16(ART &art, Node &node48, Node &node16);
42
+ //! Initializes all fields of the node while shrinking a Node256 to a Node48
43
+ static Node48 &ShrinkNode256(ART &art, Node &node48, Node &node256);
44
+
45
+ //! Initializes a merge by incrementing the buffer IDs of the node
46
+ void InitializeMerge(ART &art, const ARTFlags &flags);
47
+
48
+ //! Insert a child node at byte
49
+ static void InsertChild(ART &art, Node &node, const uint8_t byte, const Node child);
50
+ //! Delete the child node at the respective byte
51
+ static void DeleteChild(ART &art, Node &node, const uint8_t byte);
52
+
53
+ //! Replace the child node at the respective byte
54
+ inline void ReplaceChild(const uint8_t byte, const Node child) {
55
+ D_ASSERT(child_index[byte] != Node::EMPTY_MARKER);
56
+ children[child_index[byte]] = child;
53
57
  }
58
+
59
+ //! Get the child for the respective byte in the node
60
+ inline optional_ptr<Node> GetChild(const uint8_t byte) {
61
+ if (child_index[byte] != Node::EMPTY_MARKER) {
62
+ return &children[child_index[byte]];
63
+ }
64
+ return nullptr;
65
+ }
66
+ //! Get the first child that is greater or equal to the specific byte
67
+ optional_ptr<Node> GetNextChild(uint8_t &byte);
68
+
69
+ //! Serialize an ART node
70
+ BlockPointer Serialize(ART &art, MetaBlockWriter &writer);
71
+ //! Deserialize this node
72
+ void Deserialize(ART &art, MetaBlockReader &reader);
73
+
74
+ //! Vacuum the children of the node
75
+ void Vacuum(ART &art, const ARTFlags &flags);
54
76
  };
55
77
  } // namespace duckdb
@@ -7,71 +7,78 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
  #pragma once
9
9
 
10
- #include "duckdb/execution/index/art/art_key.hpp"
11
- #include "duckdb/storage/meta_block_reader.hpp"
12
- #include "duckdb/storage/meta_block_writer.hpp"
10
+ #include "duckdb/execution/index/art/node.hpp"
13
11
 
14
12
  namespace duckdb {
15
- class ART;
16
13
 
17
- class Prefix {
18
- static constexpr idx_t PREFIX_INLINE_BYTES = 8;
14
+ // classes
15
+ class ARTKey;
16
+ class PrefixSegment;
19
17
 
18
+ class Prefix {
20
19
  public:
21
- //! Empty prefix
22
- Prefix();
23
- //! Construct prefix from key starting at depth
24
- Prefix(Key &key, uint32_t depth, uint32_t size);
25
- //! Construct prefix from other prefix up to size
26
- Prefix(Prefix &other_prefix, uint32_t size);
27
- ~Prefix();
20
+ //! Number of bytes in this prefix
21
+ uint32_t count;
22
+ union {
23
+ //! Pointer to the head of the list of prefix segments
24
+ Node ptr;
25
+ //! Inlined prefix bytes
26
+ uint8_t inlined[Node::PREFIX_INLINE_BYTES];
27
+ } data;
28
28
 
29
- //! Returns the prefix size
30
- inline uint32_t Size() const {
31
- return size;
29
+ public:
30
+ //! Delete all prefix segments (if not inlined) and reset all fields
31
+ void Free(ART &art);
32
+ //! Initializes all the fields of an empty prefix
33
+ inline void Initialize() {
34
+ count = 0;
32
35
  }
33
- //! Returns the memory size of the prefix
34
- idx_t MemorySize();
35
- //! Returns a pointer to the prefix data
36
- uint8_t *GetPrefixData();
37
- //! Returns a const pointer to the prefix data
38
- const uint8_t *GetPrefixData() const;
36
+ //! Initialize a prefix from an ART key
37
+ void Initialize(ART &art, const ARTKey &key, const uint32_t depth, const uint32_t count_p);
38
+ //! Initialize a prefix from another prefix up to count
39
+ void Initialize(ART &art, const Prefix &other, const uint32_t count_p);
39
40
 
40
- //! Subscript operator
41
- uint8_t &operator[](idx_t idx);
42
- //! Assign operator
43
- Prefix &operator=(const Prefix &src);
44
- //! Move operator
45
- Prefix &operator=(Prefix &&other) noexcept;
41
+ //! Initializes a merge by incrementing the buffer IDs of the prefix segments
42
+ void InitializeMerge(ART &art, const idx_t buffer_count);
46
43
 
44
+ //! Move a prefix into this prefix
45
+ inline void Move(Prefix &other) {
46
+ count = other.count;
47
+ data = other.data;
48
+ other.Initialize();
49
+ }
50
+ //! Append a prefix to this prefix
51
+ void Append(ART &art, const Prefix &other);
47
52
  //! Concatenate prefix with a partial key byte and another prefix: other.prefix + byte + this->prefix
48
- //! Used when deleting a node
49
- void Concatenate(ART &art, uint8_t key, Prefix &other);
50
- //! Reduces the prefix in n bytes, and returns the new first byte
51
- uint8_t Reduce(ART &art, uint32_t n);
52
-
53
- //! Serializes the prefix
54
- void Serialize(duckdb::MetaBlockWriter &writer);
55
- //! Deserializes the prefix
56
- void Deserialize(duckdb::MetaBlockReader &reader);
53
+ void Concatenate(ART &art, const uint8_t byte, const Prefix &other);
54
+ //! Removes the first n bytes, and returns the new first byte
55
+ uint8_t Reduce(ART &art, const idx_t reduce_count);
57
56
 
57
+ //! Get the byte at position
58
+ uint8_t GetByte(const ART &art, const idx_t position) const;
58
59
  //! Compare the key with the prefix of the node, return the position where they mismatch
59
- uint32_t KeyMismatchPosition(Key &key, uint32_t depth);
60
- //! Compare this prefix to another prefix, return the position where they mismatch, or size otherwise
61
- uint32_t MismatchPosition(Prefix &other);
60
+ uint32_t KeyMismatchPosition(const ART &art, const ARTKey &key, const uint32_t depth) const;
61
+ //! Compare this prefix to another prefix, return the position where they mismatch, or count otherwise
62
+ uint32_t MismatchPosition(const ART &art, const Prefix &other) const;
62
63
 
63
- private:
64
- uint32_t size;
65
- union {
66
- uint8_t *ptr;
67
- uint8_t inlined[8];
68
- } value;
64
+ //! Serialize this prefix
65
+ void Serialize(const ART &art, MetaBlockWriter &writer) const;
66
+ //! Deserialize this prefix
67
+ void Deserialize(ART &art, MetaBlockReader &reader);
68
+
69
+ //! Vacuum the prefix segments of a prefix, if not inlined
70
+ void Vacuum(ART &art);
69
71
 
70
72
  private:
71
- bool IsInlined() const;
72
- uint8_t *AllocatePrefix(uint32_t size);
73
- void Overwrite(uint32_t new_size, uint8_t *data);
74
- void Destroy();
73
+ //! Returns whether this prefix is inlined
74
+ inline bool IsInlined() const {
75
+ return count <= Node::PREFIX_INLINE_BYTES;
76
+ }
77
+ //! Moves all inlined bytes onto a prefix segment, does not change the size
78
+ //! so this will be an (temporarily) invalid prefix
79
+ PrefixSegment &MoveInlinedToSegment(ART &art);
80
+ //! Inlines up to eight bytes on the first prefix segment
81
+ void MoveSegmentToInlined(ART &art);
75
82
  };
76
83
 
77
84
  } // namespace duckdb
@@ -0,0 +1,40 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/execution/index/art/prefix_segment.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+ #pragma once
9
+
10
+ #include "duckdb/execution/index/art/art.hpp"
11
+ #include "duckdb/execution/index/art/node.hpp"
12
+
13
+ namespace duckdb {
14
+
15
+ class PrefixSegment {
16
+ public:
17
+ //! Constructor of an empty prefix segment containing bytes.
18
+ //! NOTE: only use this constructor for temporary prefix segments
19
+ PrefixSegment() {};
20
+
21
+ //! The prefix bytes stored in this segment
22
+ uint8_t bytes[Node::PREFIX_SEGMENT_SIZE];
23
+ //! The position of the next segment, if the prefix exceeds this segment
24
+ Node next;
25
+
26
+ public:
27
+ //! Get a new prefix segment node, might cause a new buffer allocation, and initialize it
28
+ static PrefixSegment &New(ART &art, Node &node);
29
+ //! Get a reference to the prefix segment
30
+ static inline PrefixSegment &Get(const ART &art, const Node ptr) {
31
+ return *Node::GetAllocator(art, NType::PREFIX_SEGMENT).Get<PrefixSegment>(ptr);
32
+ }
33
+
34
+ //! Append a byte to the current segment, or create a new segment containing that byte
35
+ PrefixSegment &Append(ART &art, uint32_t &count, const uint8_t byte);
36
+ //! Get the tail of a list of segments
37
+ PrefixSegment &GetTail(const ART &art);
38
+ };
39
+
40
+ } // namespace duckdb