duckdb 0.7.2-dev3441.0 → 0.7.2-dev3546.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 (160) hide show
  1. package/configure.py +2 -0
  2. package/package.json +2 -2
  3. package/src/duckdb/extension/json/json_functions/json_create.cpp +1 -1
  4. package/src/duckdb/extension/json/json_functions/read_json.cpp +1 -0
  5. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +42 -0
  6. package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -0
  7. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  8. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -0
  9. package/src/duckdb/src/common/arrow/arrow_converter.cpp +4 -4
  10. package/src/duckdb/src/common/compressed_file_system.cpp +2 -2
  11. package/src/duckdb/src/common/constants.cpp +1 -0
  12. package/src/duckdb/src/common/file_system.cpp +2 -2
  13. package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
  14. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
  15. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +1 -1
  16. package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
  17. package/src/duckdb/src/common/serializer/buffered_serializer.cpp +4 -3
  18. package/src/duckdb/src/common/serializer.cpp +1 -1
  19. package/src/duckdb/src/common/sort/radix_sort.cpp +5 -5
  20. package/src/duckdb/src/common/string_util.cpp +2 -2
  21. package/src/duckdb/src/common/types/bit.cpp +2 -2
  22. package/src/duckdb/src/common/types/blob.cpp +2 -2
  23. package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
  24. package/src/duckdb/src/common/types/date.cpp +1 -1
  25. package/src/duckdb/src/common/types/decimal.cpp +2 -2
  26. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +14 -2
  27. package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
  28. package/src/duckdb/src/common/types/time.cpp +1 -1
  29. package/src/duckdb/src/common/types/vector.cpp +10 -10
  30. package/src/duckdb/src/common/types/vector_buffer.cpp +11 -3
  31. package/src/duckdb/src/common/types/vector_cache.cpp +5 -5
  32. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  33. package/src/duckdb/src/common/windows_util.cpp +2 -2
  34. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +6 -3
  35. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -5
  36. package/src/duckdb/src/core_functions/scalar/string/printf.cpp +1 -1
  37. package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
  38. package/src/duckdb/src/execution/join_hashtable.cpp +3 -3
  39. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +2 -2
  40. package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
  41. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  43. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -7
  44. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +4 -41
  45. package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +158 -0
  46. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
  47. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -2
  48. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
  49. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -4
  50. package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
  51. package/src/duckdb/src/function/macro_function.cpp +43 -0
  52. package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
  53. package/src/duckdb/src/function/scalar/strftime_format.cpp +2 -1
  54. package/src/duckdb/src/function/scalar/string/concat.cpp +1 -1
  55. package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
  56. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
  57. package/src/duckdb/src/function/scalar_macro_function.cpp +10 -0
  58. package/src/duckdb/src/function/table/copy_csv.cpp +3 -7
  59. package/src/duckdb/src/function/table/read_csv.cpp +60 -35
  60. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  61. package/src/duckdb/src/function/table_macro_function.cpp +10 -0
  62. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -1
  63. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +0 -6
  64. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +0 -6
  65. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  66. package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -3
  67. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -5
  68. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +3 -3
  69. package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -9
  70. package/src/duckdb/src/include/duckdb/common/memory_safety.hpp +15 -0
  71. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +1 -0
  72. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/common/serializer/buffered_serializer.hpp +3 -2
  75. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +2 -3
  76. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +11 -6
  77. package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -1
  78. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  79. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -3
  80. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +16 -6
  81. package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +53 -22
  82. package/src/duckdb/src/include/duckdb/common/vector.hpp +5 -2
  83. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +4 -4
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
  87. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +1 -1
  88. package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +0 -2
  89. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +27 -127
  91. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +1 -1
  94. package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +2 -2
  95. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  96. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +7 -1
  97. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +3 -4
  98. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +7 -2
  99. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +5 -0
  101. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
  102. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +4 -7
  103. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +8 -12
  104. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +6 -20
  105. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +6 -18
  106. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +4 -8
  107. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +4 -38
  108. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +5 -2
  109. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -10
  110. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +5 -0
  111. package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -2
  112. package/src/duckdb/src/include/duckdb/storage/buffer/buffer_handle.hpp +9 -2
  113. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +1 -1
  114. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
  115. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
  117. package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
  118. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +14 -6
  119. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +42 -0
  120. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +0 -7
  121. package/src/duckdb/src/parser/parsed_data/create_info.cpp +19 -8
  122. package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +46 -0
  123. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +56 -0
  124. package/src/duckdb/src/parser/parsed_data/create_type_info.cpp +47 -0
  125. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +34 -0
  126. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +46 -0
  127. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +24 -0
  128. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +37 -0
  129. package/src/duckdb/src/parser/statement/insert_statement.cpp +4 -1
  130. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +10 -0
  131. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +27 -9
  132. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
  133. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -0
  134. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +32 -7
  135. package/src/duckdb/src/planner/logical_operator.cpp +1 -2
  136. package/src/duckdb/src/planner/operator/logical_create_index.cpp +16 -25
  137. package/src/duckdb/src/planner/operator/logical_insert.cpp +30 -0
  138. package/src/duckdb/src/planner/operator/logical_simple.cpp +33 -5
  139. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +6 -16
  140. package/src/duckdb/src/planner/planner.cpp +4 -13
  141. package/src/duckdb/src/storage/arena_allocator.cpp +1 -1
  142. package/src/duckdb/src/storage/buffer/buffer_handle.cpp +2 -11
  143. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +1 -1
  144. package/src/duckdb/src/storage/checkpoint_manager.cpp +12 -6
  145. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +2 -2
  146. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  147. package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
  148. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  149. package/src/duckdb/src/storage/table/row_group.cpp +2 -2
  150. package/src/duckdb/src/storage/table/update_segment.cpp +7 -6
  151. package/src/duckdb/third_party/fsst/libfsst.cpp +1 -2
  152. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +9 -0
  153. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +13 -12
  154. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
  155. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12537 -12415
  156. package/src/duckdb/ub_src_catalog_catalog_entry.cpp +1 -1
  157. package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
  158. package/src/duckdb/ub_src_parser_parsed_data.cpp +16 -0
  159. package/src/statement.cpp +15 -13
  160. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +0 -104
@@ -36,12 +36,12 @@ struct ExportAggregateBindData : public FunctionData {
36
36
  struct CombineState : public FunctionLocalState {
37
37
  idx_t state_size;
38
38
 
39
- unique_ptr<data_t[]> state_buffer0, state_buffer1;
39
+ unsafe_array_ptr<data_t> state_buffer0, state_buffer1;
40
40
  Vector state_vector0, state_vector1;
41
41
 
42
42
  explicit CombineState(idx_t state_size_p)
43
- : state_size(state_size_p), state_buffer0(unique_ptr<data_t[]>(new data_t[state_size_p])),
44
- state_buffer1(unique_ptr<data_t[]>(new data_t[state_size_p])),
43
+ : state_size(state_size_p), state_buffer0(make_unsafe_array<data_t>(state_size_p)),
44
+ state_buffer1(make_unsafe_array<data_t>(state_size_p)),
45
45
  state_vector0(Value::POINTER((uintptr_t)state_buffer0.get())),
46
46
  state_vector1(Value::POINTER((uintptr_t)state_buffer1.get())) {
47
47
  }
@@ -55,12 +55,12 @@ static unique_ptr<FunctionLocalState> InitCombineState(ExpressionState &state, c
55
55
 
56
56
  struct FinalizeState : public FunctionLocalState {
57
57
  idx_t state_size;
58
- unique_ptr<data_t[]> state_buffer;
58
+ unsafe_array_ptr<data_t> state_buffer;
59
59
  Vector addresses;
60
60
 
61
61
  explicit FinalizeState(idx_t state_size_p)
62
62
  : state_size(state_size_p),
63
- state_buffer(unique_ptr<data_t[]>(new data_t[STANDARD_VECTOR_SIZE * AlignValue(state_size_p)])),
63
+ state_buffer(make_unsafe_array<data_t>(STANDARD_VECTOR_SIZE * AlignValue(state_size_p))),
64
64
  addresses(LogicalType::POINTER) {
65
65
  }
66
66
  };
@@ -49,4 +49,14 @@ string ScalarMacroFunction::ToSQL(const string &schema, const string &name) cons
49
49
  return MacroFunction::ToSQL(schema, name) + StringUtil::Format("(%s);", expression_copy->ToString());
50
50
  }
51
51
 
52
+ void ScalarMacroFunction::SerializeInternal(FieldWriter &writer) const {
53
+ writer.WriteSerializable(*expression);
54
+ }
55
+
56
+ unique_ptr<MacroFunction> ScalarMacroFunction::Deserialize(FieldReader &reader) {
57
+ auto result = make_uniq<ScalarMacroFunction>();
58
+ result->expression = reader.ReadRequiredSerializable<ParsedExpression>();
59
+ return std::move(result);
60
+ }
61
+
52
62
  } // namespace duckdb
@@ -78,7 +78,7 @@ static unique_ptr<FunctionData> WriteCSVBind(ClientContext &context, CopyInfo &i
78
78
  bind_data->is_simple = bind_data->options.delimiter.size() == 1 && bind_data->options.escape.size() == 1 &&
79
79
  bind_data->options.quote.size() == 1;
80
80
  if (bind_data->is_simple) {
81
- bind_data->requires_quotes = unique_ptr<bool[]>(new bool[256]);
81
+ bind_data->requires_quotes = make_unsafe_array<bool>(256);
82
82
  memset(bind_data->requires_quotes.get(), 0, sizeof(bool) * 256);
83
83
  bind_data->requires_quotes['\n'] = true;
84
84
  bind_data->requires_quotes['\r'] = true;
@@ -324,15 +324,11 @@ static void WriteCSVChunkInternal(ClientContext &context, FunctionData &bind_dat
324
324
  csv_data.options.write_date_format[LogicalTypeId::DATE].ConvertDateVector(
325
325
  input.data[col_idx], cast_chunk.data[col_idx], input.size());
326
326
  } else if (options.has_format[LogicalTypeId::TIMESTAMP] &&
327
- csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP) {
327
+ (csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP ||
328
+ csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP_TZ)) {
328
329
  // use the timestamp format to cast the chunk
329
330
  csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP].ConvertTimestampVector(
330
331
  input.data[col_idx], cast_chunk.data[col_idx], input.size());
331
- } else if (options.has_format[LogicalTypeId::TIMESTAMP_TZ] &&
332
- csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP_TZ) {
333
- // use the timestamp format to cast the chunk
334
- csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP_TZ].ConvertTimestampVector(
335
- input.data[col_idx], cast_chunk.data[col_idx], input.size());
336
332
  } else {
337
333
  // non varchar column, perform the cast
338
334
  VectorOperations::Cast(context, input.data[col_idx], cast_chunk.data[col_idx], input.size());
@@ -4,7 +4,6 @@
4
4
  #include "duckdb/main/database.hpp"
5
5
  #include "duckdb/common/string_util.hpp"
6
6
  #include "duckdb/common/enum_util.hpp"
7
- #include "duckdb/common/hive_partitioning.hpp"
8
7
  #include "duckdb/common/union_by_name.hpp"
9
8
  #include "duckdb/main/config.hpp"
10
9
  #include "duckdb/parser/expression/constant_expression.hpp"
@@ -15,7 +14,6 @@
15
14
  #include "duckdb/common/multi_file_reader.hpp"
16
15
  #include "duckdb/main/client_data.hpp"
17
16
  #include "duckdb/execution/operator/persistent/csv_line_info.hpp"
18
-
19
17
  #include <limits>
20
18
 
21
19
  namespace duckdb {
@@ -23,11 +21,8 @@ namespace duckdb {
23
21
  unique_ptr<CSVFileHandle> ReadCSV::OpenCSV(const string &file_path, FileCompressionType compression,
24
22
  ClientContext &context) {
25
23
  auto &fs = FileSystem::GetFileSystem(context);
26
- auto file_handle = fs.OpenFile(file_path.c_str(), FileFlags::FILE_FLAGS_READ, FileLockType::NO_LOCK, compression);
27
- if (file_handle->CanSeek()) {
28
- file_handle->Reset();
29
- }
30
- return make_uniq<CSVFileHandle>(std::move(file_handle), false);
24
+ auto &allocator = BufferAllocator::Get(context);
25
+ return CSVFileHandle::OpenFile(fs, allocator, file_path, compression, false);
31
26
  }
32
27
 
33
28
  void ReadCSVData::FinalizeRead(ClientContext &context) {
@@ -238,14 +233,6 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
238
233
  } else {
239
234
  result->reader_bind = MultiFileReader::BindOptions(options.file_options, result->files, return_types, names);
240
235
  }
241
- auto &fs = FileSystem::GetFileSystem(context);
242
- for (auto &file : result->files) {
243
- if (fs.IsPipe(file)) {
244
- result->is_pipe = true;
245
- result->single_threaded = true;
246
- break;
247
- }
248
- }
249
236
  result->return_types = return_types;
250
237
  result->return_names = names;
251
238
  result->FinalizeRead(context);
@@ -265,7 +252,7 @@ static unique_ptr<FunctionData> ReadCSVAutoBind(ClientContext &context, TableFun
265
252
  struct ParallelCSVGlobalState : public GlobalTableFunctionState {
266
253
  public:
267
254
  ParallelCSVGlobalState(ClientContext &context, unique_ptr<CSVFileHandle> file_handle_p,
268
- vector<string> &files_path_p, idx_t system_threads_p, idx_t buffer_size_p,
255
+ const vector<string> &files_path_p, idx_t system_threads_p, idx_t buffer_size_p,
269
256
  idx_t rows_to_skip, bool force_parallelism_p, vector<column_t> column_ids_p, bool has_header)
270
257
  : file_handle(std::move(file_handle_p)), system_threads(system_threads_p), buffer_size(buffer_size_p),
271
258
  force_parallelism(force_parallelism_p), column_ids(std::move(column_ids_p)),
@@ -278,6 +265,7 @@ public:
278
265
  }
279
266
  file_size = file_handle->FileSize();
280
267
  first_file_size = file_size;
268
+ on_disk_file = file_handle->OnDiskFile();
281
269
  bytes_read = 0;
282
270
  if (buffer_size < file_size || file_size == 0) {
283
271
  bytes_per_local_state = buffer_size / ParallelCSVGlobalState::MaxThreads();
@@ -335,7 +323,7 @@ public:
335
323
 
336
324
  bool Finished();
337
325
 
338
- double GetProgress(ReadCSVData &bind_data) const {
326
+ double GetProgress(const ReadCSVData &bind_data) const {
339
327
  idx_t total_files = bind_data.files.size();
340
328
 
341
329
  // get the progress WITHIN the current file
@@ -369,6 +357,8 @@ private:
369
357
  idx_t bytes_per_local_state;
370
358
  //! Size of first file
371
359
  idx_t first_file_size;
360
+ //! Whether or not this is an on-disk file
361
+ bool on_disk_file = true;
372
362
  //! Basically max number of threads in DuckDB
373
363
  idx_t system_threads;
374
364
  //! Size of the buffers
@@ -402,7 +392,7 @@ private:
402
392
  };
403
393
 
404
394
  idx_t ParallelCSVGlobalState::MaxThreads() const {
405
- if (force_parallelism) {
395
+ if (force_parallelism || !on_disk_file) {
406
396
  return system_threads;
407
397
  }
408
398
  idx_t one_mb = 1000000; // We initialize max one thread per Mb
@@ -628,7 +618,7 @@ idx_t LineInfo::GetLine(idx_t batch_idx, idx_t line_error, idx_t file_idx, idx_t
628
618
 
629
619
  static unique_ptr<GlobalTableFunctionState> ParallelCSVInitGlobal(ClientContext &context,
630
620
  TableFunctionInitInput &input) {
631
- auto &bind_data = (ReadCSVData &)*input.bind_data;
621
+ auto &bind_data = input.bind_data->CastNoConst<ReadCSVData>();
632
622
  if (bind_data.files.empty()) {
633
623
  // This can happen when a filename based filter pushdown has eliminated all possible files for this scan.
634
624
  return make_uniq<ParallelCSVGlobalState>();
@@ -636,7 +626,15 @@ static unique_ptr<GlobalTableFunctionState> ParallelCSVInitGlobal(ClientContext
636
626
  unique_ptr<CSVFileHandle> file_handle;
637
627
 
638
628
  bind_data.options.file_path = bind_data.files[0];
639
- file_handle = ReadCSV::OpenCSV(bind_data.options.file_path, bind_data.options.compression, context);
629
+
630
+ if (bind_data.initial_reader) {
631
+ file_handle = std::move(bind_data.initial_reader->file_handle);
632
+ file_handle->Reset();
633
+ file_handle->DisableReset();
634
+ bind_data.initial_reader.reset();
635
+ } else {
636
+ file_handle = ReadCSV::OpenCSV(bind_data.options.file_path, bind_data.options.compression, context);
637
+ }
640
638
  return make_uniq<ParallelCSVGlobalState>(
641
639
  context, std::move(file_handle), bind_data.files, context.db->NumberOfThreads(), bind_data.options.buffer_size,
642
640
  bind_data.options.skip_rows, ClientConfig::GetConfig(context).verify_parallelism, input.column_ids,
@@ -738,7 +736,7 @@ struct SingleThreadedCSVState : public GlobalTableFunctionState {
738
736
  return total_files;
739
737
  }
740
738
 
741
- double GetProgress(ReadCSVData &bind_data) const {
739
+ double GetProgress(const ReadCSVData &bind_data) const {
742
740
  D_ASSERT(total_files == bind_data.files.size());
743
741
  D_ASSERT(progress_in_files <= total_files * 100);
744
742
  return (double(progress_in_files) / double(total_files));
@@ -746,6 +744,16 @@ struct SingleThreadedCSVState : public GlobalTableFunctionState {
746
744
 
747
745
  unique_ptr<BufferedCSVReader> GetCSVReader(ClientContext &context, ReadCSVData &bind_data, idx_t &file_index,
748
746
  idx_t &total_size) {
747
+ auto reader = GetCSVReaderInternal(context, bind_data, file_index, total_size);
748
+ if (reader) {
749
+ reader->file_handle->DisableReset();
750
+ }
751
+ return reader;
752
+ }
753
+
754
+ private:
755
+ unique_ptr<BufferedCSVReader> GetCSVReaderInternal(ClientContext &context, ReadCSVData &bind_data,
756
+ idx_t &file_index, idx_t &total_size) {
749
757
  BufferedCSVReaderOptions options;
750
758
  {
751
759
  lock_guard<mutex> l(csv_lock);
@@ -799,14 +807,14 @@ public:
799
807
 
800
808
  static unique_ptr<GlobalTableFunctionState> SingleThreadedCSVInit(ClientContext &context,
801
809
  TableFunctionInitInput &input) {
802
- auto &bind_data = (ReadCSVData &)*input.bind_data;
810
+ auto &bind_data = input.bind_data->CastNoConst<ReadCSVData>();
803
811
  auto result = make_uniq<SingleThreadedCSVState>(bind_data.files.size());
804
812
  if (bind_data.files.empty()) {
805
813
  // This can happen when a filename based filter pushdown has eliminated all possible files for this scan.
806
814
  return std::move(result);
807
815
  } else {
808
816
  bind_data.options.file_path = bind_data.files[0];
809
- if (bind_data.initial_reader && bind_data.is_pipe) {
817
+ if (bind_data.initial_reader) {
810
818
  // If this is a pipe and an initial reader already exists due to read_csv_auto
811
819
  // We must re-use it, since we can't restart the reader due for it being a pipe.
812
820
  result->initial_reader = std::move(bind_data.initial_reader);
@@ -904,7 +912,7 @@ static void SingleThreadedCSVFunction(ClientContext &context, TableFunctionInput
904
912
  // Read CSV Functions
905
913
  //===--------------------------------------------------------------------===//
906
914
  static unique_ptr<GlobalTableFunctionState> ReadCSVInitGlobal(ClientContext &context, TableFunctionInitInput &input) {
907
- auto &bind_data = (ReadCSVData &)*input.bind_data;
915
+ auto &bind_data = input.bind_data->Cast<ReadCSVData>();
908
916
  if (bind_data.single_threaded) {
909
917
  return SingleThreadedCSVInit(context, input);
910
918
  } else {
@@ -914,7 +922,7 @@ static unique_ptr<GlobalTableFunctionState> ReadCSVInitGlobal(ClientContext &con
914
922
 
915
923
  unique_ptr<LocalTableFunctionState> ReadCSVInitLocal(ExecutionContext &context, TableFunctionInitInput &input,
916
924
  GlobalTableFunctionState *global_state_p) {
917
- auto &csv_data = (ReadCSVData &)*input.bind_data;
925
+ auto &csv_data = input.bind_data->Cast<ReadCSVData>();
918
926
  if (csv_data.single_threaded) {
919
927
  return SingleThreadedReadCSVInitLocal(context, input, global_state_p);
920
928
  } else {
@@ -923,7 +931,7 @@ unique_ptr<LocalTableFunctionState> ReadCSVInitLocal(ExecutionContext &context,
923
931
  }
924
932
 
925
933
  static void ReadCSVFunction(ClientContext &context, TableFunctionInput &data_p, DataChunk &output) {
926
- auto &bind_data = (ReadCSVData &)*data_p.bind_data;
934
+ auto &bind_data = data_p.bind_data->Cast<ReadCSVData>();
927
935
  if (bind_data.single_threaded) {
928
936
  SingleThreadedCSVFunction(context, data_p, output);
929
937
  } else {
@@ -933,7 +941,7 @@ static void ReadCSVFunction(ClientContext &context, TableFunctionInput &data_p,
933
941
 
934
942
  static idx_t CSVReaderGetBatchIndex(ClientContext &context, const FunctionData *bind_data_p,
935
943
  LocalTableFunctionState *local_state, GlobalTableFunctionState *global_state) {
936
- auto &bind_data = (ReadCSVData &)*bind_data_p;
944
+ auto &bind_data = bind_data_p->Cast<ReadCSVData>();
937
945
  if (bind_data.single_threaded) {
938
946
  auto &data = local_state->Cast<SingleThreadedCSVLocalState>();
939
947
  return data.file_index;
@@ -980,28 +988,28 @@ static void ReadCSVAddNamedParameters(TableFunction &table_function) {
980
988
 
981
989
  double CSVReaderProgress(ClientContext &context, const FunctionData *bind_data_p,
982
990
  const GlobalTableFunctionState *global_state) {
983
- auto &bind_data = (ReadCSVData &)*bind_data_p;
991
+ auto &bind_data = bind_data_p->Cast<ReadCSVData>();
984
992
  if (bind_data.single_threaded) {
985
- auto &data = (SingleThreadedCSVState &)*global_state;
993
+ auto &data = global_state->Cast<SingleThreadedCSVState>();
986
994
  return data.GetProgress(bind_data);
987
995
  } else {
988
- auto &data = (const ParallelCSVGlobalState &)*global_state;
996
+ auto &data = global_state->Cast<ParallelCSVGlobalState>();
989
997
  return data.GetProgress(bind_data);
990
998
  }
991
999
  }
992
1000
 
993
1001
  void CSVComplexFilterPushdown(ClientContext &context, LogicalGet &get, FunctionData *bind_data_p,
994
1002
  vector<unique_ptr<Expression>> &filters) {
995
- auto data = (ReadCSVData *)bind_data_p;
1003
+ auto &data = bind_data_p->Cast<ReadCSVData>();
996
1004
  auto reset_reader =
997
- MultiFileReader::ComplexFilterPushdown(context, data->files, data->options.file_options, get, filters);
1005
+ MultiFileReader::ComplexFilterPushdown(context, data.files, data.options.file_options, get, filters);
998
1006
  if (reset_reader) {
999
- MultiFileReader::PruneReaders(*data);
1007
+ MultiFileReader::PruneReaders(data);
1000
1008
  }
1001
1009
  }
1002
1010
 
1003
1011
  unique_ptr<NodeStatistics> CSVReaderCardinality(ClientContext &context, const FunctionData *bind_data_p) {
1004
- auto &bind_data = (ReadCSVData &)*bind_data_p;
1012
+ auto &bind_data = bind_data_p->Cast<ReadCSVData>();
1005
1013
  idx_t per_file_cardinality = 0;
1006
1014
  if (bind_data.initial_reader && bind_data.initial_reader->file_handle) {
1007
1015
  auto estimated_row_width = (bind_data.csv_types.size() * 5);
@@ -1047,6 +1055,12 @@ void BufferedCSVReaderOptions::Serialize(FieldWriter &writer) const {
1047
1055
  writer.WriteSerializable(file_options);
1048
1056
  // write options
1049
1057
  writer.WriteListNoReference<bool>(force_quote);
1058
+ // FIXME: serialize date_format / has_format
1059
+ vector<string> csv_formats;
1060
+ for (auto &format : date_format) {
1061
+ csv_formats.push_back(format.second.format_specifier);
1062
+ }
1063
+ writer.WriteList<string>(csv_formats);
1050
1064
  }
1051
1065
 
1052
1066
  void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
@@ -1083,10 +1097,21 @@ void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
1083
1097
  file_options = reader.ReadRequiredSerializable<MultiFileReaderOptions, MultiFileReaderOptions>();
1084
1098
  // write options
1085
1099
  force_quote = reader.ReadRequiredList<bool>();
1100
+ auto formats = reader.ReadRequiredList<string>();
1101
+ vector<LogicalTypeId> format_types {LogicalTypeId::DATE, LogicalTypeId::TIMESTAMP};
1102
+ for (idx_t f_idx = 0; f_idx < formats.size(); f_idx++) {
1103
+ auto &format = formats[f_idx];
1104
+ auto &type = format_types[f_idx];
1105
+ if (format.empty()) {
1106
+ continue;
1107
+ }
1108
+ has_format[type] = true;
1109
+ StrTimeFormat::ParseFormatSpecifier(format, date_format[type]);
1110
+ }
1086
1111
  }
1087
1112
 
1088
1113
  static void CSVReaderSerialize(FieldWriter &writer, const FunctionData *bind_data_p, const TableFunction &function) {
1089
- auto &bind_data = (ReadCSVData &)*bind_data_p;
1114
+ auto &bind_data = bind_data_p->Cast<ReadCSVData>();
1090
1115
  writer.WriteList<string>(bind_data.files);
1091
1116
  writer.WriteRegularSerializableList<LogicalType>(bind_data.csv_types);
1092
1117
  writer.WriteList<string>(bind_data.csv_names);
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.2-dev3441"
2
+ #define DUCKDB_VERSION "0.7.2-dev3546"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "e97702367a"
5
+ #define DUCKDB_SOURCE_ID "bd8adef6d1"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -31,4 +31,14 @@ string TableMacroFunction::ToSQL(const string &schema, const string &name) const
31
31
  return MacroFunction::ToSQL(schema, name) + StringUtil::Format("TABLE (%s);", query_node->ToString());
32
32
  }
33
33
 
34
+ void TableMacroFunction::SerializeInternal(FieldWriter &writer) const {
35
+ writer.WriteSerializable(*query_node);
36
+ }
37
+
38
+ unique_ptr<MacroFunction> TableMacroFunction::Deserialize(FieldReader &reader) {
39
+ auto result = make_uniq<TableMacroFunction>();
40
+ result->query_node = reader.ReadRequiredSerializable<QueryNode>();
41
+ return std::move(result);
42
+ }
43
+
34
44
  } // namespace duckdb
@@ -24,8 +24,10 @@ public:
24
24
  unique_ptr<MacroFunction> function;
25
25
 
26
26
  public:
27
+ virtual unique_ptr<CreateMacroInfo> GetInfoForSerialization() const;
27
28
  //! Serialize the meta information
28
- virtual void Serialize(Serializer &serializer) const = 0;
29
+ virtual void Serialize(Serializer &serializer) const;
30
+ static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &main_source, ClientContext &context);
29
31
 
30
32
  string ToSQL() const override {
31
33
  return function->ToSQL(schema.name, name);
@@ -23,11 +23,5 @@ public:
23
23
 
24
24
  public:
25
25
  ScalarMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info);
26
-
27
- public:
28
- //! Serialize the meta information of the ScalarMacroCatalogEntry
29
- void Serialize(Serializer &serializer) const override;
30
- //! Deserializes to a CreateMacroInfo
31
- static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &source, ClientContext &context);
32
26
  };
33
27
  } // namespace duckdb
@@ -22,12 +22,6 @@ public:
22
22
 
23
23
  public:
24
24
  TableMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info);
25
-
26
- public:
27
- //! Serialize the meta information of the ScalarMacroCatalogEntry
28
- void Serialize(Serializer &serializer) const override;
29
- //! Deserializes to a CreateMacroInfo
30
- static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &source, ClientContext &context);
31
25
  };
32
26
 
33
27
  } // namespace duckdb
@@ -54,6 +54,9 @@ public:
54
54
  idx_t GetSize() const {
55
55
  return allocated_size;
56
56
  }
57
+ bool IsSet() {
58
+ return pointer;
59
+ }
57
60
  void Reset();
58
61
 
59
62
  private:
@@ -18,8 +18,8 @@ struct StreamData {
18
18
  // various buffers & pointers
19
19
  bool write = false;
20
20
  bool refresh = false;
21
- unique_ptr<data_t[]> in_buff;
22
- unique_ptr<data_t[]> out_buff;
21
+ unsafe_array_ptr<data_t> in_buff;
22
+ unsafe_array_ptr<data_t> out_buff;
23
23
  data_ptr_t out_buff_start = nullptr;
24
24
  data_ptr_t out_buff_end = nullptr;
25
25
  data_ptr_t in_buff_start = nullptr;
@@ -59,7 +59,7 @@ public:
59
59
  class CompressedFile : public FileHandle {
60
60
  public:
61
61
  DUCKDB_API CompressedFile(CompressedFileSystem &fs, unique_ptr<FileHandle> child_handle_p, const string &path);
62
- DUCKDB_API virtual ~CompressedFile() override;
62
+ DUCKDB_API ~CompressedFile() override;
63
63
 
64
64
  CompressedFileSystem &compressed_fs;
65
65
  unique_ptr<FileHandle> child_handle;
@@ -15,17 +15,14 @@
15
15
  #include "duckdb/common/typedefs.hpp"
16
16
 
17
17
  namespace duckdb {
18
+ class Serializer;
19
+ class Deserializer;
18
20
 
19
21
  //! inline std directives that we use frequently
20
22
  #ifndef DUCKDB_DEBUG_MOVE
21
23
  using std::move;
22
24
  #endif
23
25
 
24
- // template <class _Tp, class _Dp = std::default_delete<_Tp>>
25
- // class unique_ptr;
26
-
27
- // using data_ptr = unique_ptr<char[]>;
28
-
29
26
  // NOTE: there is a copy of this in the Postgres' parser grammar (gram.y)
30
27
  #define DEFAULT_SCHEMA "main"
31
28
  #define INVALID_SCHEMA ""
@@ -263,15 +263,15 @@ public:
263
263
  return ReadRequiredGenericList<T, idx_t, IndexReadOperation>();
264
264
  }
265
265
 
266
- template <class T>
267
- set<T> ReadRequiredSet() {
266
+ template <class T, class CONTAINER_TYPE = set<T>>
267
+ CONTAINER_TYPE ReadRequiredSet() {
268
268
  if (field_count >= max_field_count) {
269
269
  // field is not there, throw an exception
270
270
  throw SerializationException("Attempting to read a required field, but field is missing");
271
271
  }
272
272
  AddField();
273
273
  auto result_count = source.Read<uint32_t>();
274
- set<T> result;
274
+ CONTAINER_TYPE result;
275
275
  for (idx_t i = 0; i < result_count; i++) {
276
276
  result.insert(source.Read<T>());
277
277
  }
@@ -37,10 +37,10 @@ namespace duckdb {
37
37
  #define DUCKDB_EXPLICIT_FALLTHROUGH
38
38
  #endif
39
39
 
40
- template<class _Tp>
40
+ template<class _Tp, bool SAFE = true>
41
41
  struct __unique_if
42
42
  {
43
- typedef unique_ptr<_Tp> __unique_single;
43
+ typedef unique_ptr<_Tp, SAFE> __unique_single;
44
44
  };
45
45
 
46
46
  template<class _Tp>
@@ -57,19 +57,32 @@ struct __unique_if<_Tp[_Np]>
57
57
 
58
58
  template<class _Tp, class... _Args>
59
59
  inline
60
- typename __unique_if<_Tp>::__unique_single
60
+ typename __unique_if<_Tp, true>::__unique_single
61
61
  make_uniq(_Args&&... __args)
62
62
  {
63
- return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
63
+ return unique_ptr<_Tp, true>(new _Tp(std::forward<_Args>(__args)...));
64
64
  }
65
65
 
66
- template<class _Tp>
66
+ template<class _Tp, class... _Args>
67
67
  inline
68
- typename __unique_if<_Tp>::__unique_array_unknown_bound
69
- make_uniq(size_t __n)
68
+ typename __unique_if<_Tp, false>::__unique_single
69
+ make_unsafe_uniq(_Args&&... __args)
70
+ {
71
+ return unique_ptr<_Tp, false>(new _Tp(std::forward<_Args>(__args)...));
72
+ }
73
+
74
+ template<class _Tp>
75
+ inline unique_ptr<_Tp[], true>
76
+ make_array(size_t __n)
77
+ {
78
+ return unique_ptr<_Tp[], true>(new _Tp[__n]());
79
+ }
80
+
81
+ template<class _Tp>
82
+ inline unique_ptr<_Tp[], false>
83
+ make_unsafe_array(size_t __n)
70
84
  {
71
- typedef typename std::remove_extent<_Tp>::type _Up;
72
- return unique_ptr<_Tp>(new _Up[__n]());
85
+ return unique_ptr<_Tp[], false>(new _Tp[__n]());
73
86
  }
74
87
 
75
88
  template<class _Tp, class... _Args>
@@ -0,0 +1,15 @@
1
+ #pragma once
2
+
3
+ namespace duckdb {
4
+
5
+ template <bool ENABLED>
6
+ struct MemorySafety {
7
+ #ifdef DEBUG
8
+ // In DEBUG mode safety is always on
9
+ static constexpr bool enabled = true;
10
+ #else
11
+ static constexpr bool enabled = ENABLED;
12
+ #endif
13
+ };
14
+
15
+ } // namespace duckdb
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/common/exception.hpp"
12
+ #include "duckdb/common/unique_ptr.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -18,7 +18,7 @@ public:
18
18
  FileLockType lock_type = FileLockType::READ_LOCK, optional_ptr<FileOpener> opener = nullptr);
19
19
 
20
20
  FileSystem &fs;
21
- unique_ptr<data_t[]> data;
21
+ unsafe_array_ptr<data_t> data;
22
22
  idx_t offset;
23
23
  idx_t read_data;
24
24
  unique_ptr<FileHandle> handle;
@@ -25,7 +25,7 @@ public:
25
25
 
26
26
  FileSystem &fs;
27
27
  string path;
28
- unique_ptr<data_t[]> data;
28
+ unsafe_array_ptr<data_t> data;
29
29
  idx_t offset;
30
30
  idx_t total_written;
31
31
  unique_ptr<FileHandle> handle;
@@ -9,13 +9,14 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/common/serializer.hpp"
12
+ #include "duckdb/common/unique_ptr.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
15
16
  #define SERIALIZER_DEFAULT_SIZE 1024
16
17
 
17
18
  struct BinaryData {
18
- unique_ptr<data_t[]> data;
19
+ unsafe_array_ptr<data_t> data;
19
20
  idx_t size;
20
21
  };
21
22
 
@@ -25,7 +26,7 @@ public:
25
26
  //! writing past the initial threshold
26
27
  DUCKDB_API explicit BufferedSerializer(idx_t maximum_size = SERIALIZER_DEFAULT_SIZE);
27
28
  //! Serializes to a provided (owned) data pointer
28
- BufferedSerializer(unique_ptr<data_t[]> data, idx_t size);
29
+ BufferedSerializer(unsafe_array_ptr<data_t> data, idx_t size);
29
30
  BufferedSerializer(data_ptr_t data, idx_t size);
30
31
 
31
32
  idx_t maximum_size;
@@ -65,10 +65,9 @@ struct is_unordered_map<typename std::unordered_map<Args...>> : std::true_type {
65
65
  template <typename T>
66
66
  struct is_unique_ptr : std::false_type {};
67
67
 
68
- template <typename T, typename D>
69
- struct is_unique_ptr<unique_ptr<T, D>> : std::true_type {
68
+ template <typename T>
69
+ struct is_unique_ptr<unique_ptr<T>> : std::true_type {
70
70
  typedef T ELEMENT_TYPE;
71
- typedef D DELETER_TYPE;
72
71
  };
73
72
 
74
73
  template <typename T>
@@ -25,6 +25,7 @@ applications, and to alter it and redistribute it freely, subject to the followi
25
25
  #include "duckdb/common/fast_mem.hpp"
26
26
  #include "duckdb/common/helper.hpp"
27
27
  #include "duckdb/common/types.hpp"
28
+ #include "duckdb/common/unique_ptr.hpp"
28
29
 
29
30
  #include <algorithm>
30
31
  #include <cstddef>
@@ -38,6 +39,10 @@ using duckdb::idx_t;
38
39
  using duckdb::data_t;
39
40
  using duckdb::data_ptr_t;
40
41
  using duckdb::unique_ptr;
42
+ using duckdb::array_ptr;
43
+ using duckdb::unsafe_array_ptr;
44
+ using duckdb::make_array;
45
+ using duckdb::make_unsafe_array;
41
46
  using duckdb::FastMemcpy;
42
47
  using duckdb::FastMemcmp;
43
48
 
@@ -73,9 +78,9 @@ inline int log2(T n) {
73
78
  struct PDQConstants {
74
79
  PDQConstants(idx_t entry_size, idx_t comp_offset, idx_t comp_size, data_ptr_t end)
75
80
  : entry_size(entry_size), comp_offset(comp_offset), comp_size(comp_size),
76
- tmp_buf_ptr(unique_ptr<data_t[]>(new data_t[entry_size])), tmp_buf(tmp_buf_ptr.get()),
77
- iter_swap_buf_ptr(unique_ptr<data_t[]>(new data_t[entry_size])), iter_swap_buf(iter_swap_buf_ptr.get()),
78
- swap_offsets_buf_ptr(unique_ptr<data_t[]>(new data_t[entry_size])),
81
+ tmp_buf_ptr(make_unsafe_array<data_t>(entry_size)), tmp_buf(tmp_buf_ptr.get()),
82
+ iter_swap_buf_ptr(make_unsafe_array<data_t>(entry_size)), iter_swap_buf(iter_swap_buf_ptr.get()),
83
+ swap_offsets_buf_ptr(make_unsafe_array<data_t>(entry_size)),
79
84
  swap_offsets_buf(swap_offsets_buf_ptr.get()), end(end) {
80
85
  }
81
86
 
@@ -83,13 +88,13 @@ struct PDQConstants {
83
88
  const idx_t comp_offset;
84
89
  const idx_t comp_size;
85
90
 
86
- unique_ptr<data_t[]> tmp_buf_ptr;
91
+ unsafe_array_ptr<data_t> tmp_buf_ptr;
87
92
  const data_ptr_t tmp_buf;
88
93
 
89
- unique_ptr<data_t[]> iter_swap_buf_ptr;
94
+ unsafe_array_ptr<data_t> iter_swap_buf_ptr;
90
95
  const data_ptr_t iter_swap_buf;
91
96
 
92
- unique_ptr<data_t[]> swap_offsets_buf_ptr;
97
+ unsafe_array_ptr<data_t> swap_offsets_buf_ptr;
93
98
  const data_ptr_t swap_offsets_buf;
94
99
 
95
100
  const data_ptr_t end;