duckdb 0.7.2-dev3710.0 → 0.7.2-dev3763.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 (94) hide show
  1. package/package.json +1 -1
  2. package/src/database.cpp +0 -1
  3. package/src/duckdb/extension/json/json_functions/read_json.cpp +3 -3
  4. package/src/duckdb/extension/json/json_scan.cpp +16 -12
  5. package/src/duckdb/src/common/arrow/arrow_converter.cpp +4 -4
  6. package/src/duckdb/src/common/compressed_file_system.cpp +2 -2
  7. package/src/duckdb/src/common/file_system.cpp +2 -2
  8. package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
  9. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
  10. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +1 -1
  11. package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
  12. package/src/duckdb/src/common/serializer/buffered_serializer.cpp +3 -3
  13. package/src/duckdb/src/common/serializer.cpp +1 -1
  14. package/src/duckdb/src/common/sort/radix_sort.cpp +5 -5
  15. package/src/duckdb/src/common/string_util.cpp +6 -2
  16. package/src/duckdb/src/common/types/bit.cpp +2 -2
  17. package/src/duckdb/src/common/types/blob.cpp +2 -2
  18. package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
  19. package/src/duckdb/src/common/types/date.cpp +1 -1
  20. package/src/duckdb/src/common/types/decimal.cpp +2 -2
  21. package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
  22. package/src/duckdb/src/common/types/time.cpp +1 -1
  23. package/src/duckdb/src/common/types/vector.cpp +7 -7
  24. package/src/duckdb/src/common/windows_util.cpp +2 -2
  25. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +1 -1
  26. package/src/duckdb/src/core_functions/scalar/string/printf.cpp +1 -1
  27. package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
  28. package/src/duckdb/src/execution/join_hashtable.cpp +3 -3
  29. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +2 -2
  30. package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
  31. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
  32. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  33. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
  34. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +91 -30
  35. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
  36. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +1 -1
  37. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
  38. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -3
  39. package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
  40. package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
  41. package/src/duckdb/src/function/scalar/strftime_format.cpp +1 -1
  42. package/src/duckdb/src/function/scalar/string/concat.cpp +1 -1
  43. package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
  44. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
  45. package/src/duckdb/src/function/table/copy_csv.cpp +1 -1
  46. package/src/duckdb/src/function/table/table_scan.cpp +7 -3
  47. package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -6
  48. package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +2 -2
  49. package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -9
  50. package/src/duckdb/src/include/duckdb/common/http_state.hpp +2 -2
  51. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +1 -1
  52. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
  53. package/src/duckdb/src/include/duckdb/common/serializer/buffered_serializer.hpp +2 -2
  54. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +10 -10
  55. package/src/duckdb/src/include/duckdb/common/string_util.hpp +2 -0
  56. package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +1 -1
  57. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  58. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -3
  59. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +4 -4
  60. package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +8 -8
  61. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
  62. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +3 -3
  63. package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +1 -1
  64. package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
  65. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +1 -1
  66. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -2
  67. package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
  68. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -3
  69. package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +2 -2
  70. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  71. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -1
  72. package/src/duckdb/src/include/duckdb/main/client_data.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
  74. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +4 -0
  75. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +1 -1
  76. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
  77. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +1 -1
  78. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +5 -5
  79. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
  80. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +1 -1
  81. package/src/duckdb/src/main/client_context.cpp +4 -4
  82. package/src/duckdb/src/main/extension/extension_install.cpp +2 -2
  83. package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
  84. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +7 -1
  85. package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -1
  86. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +1 -1
  87. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +2 -2
  88. package/src/duckdb/src/storage/data_table.cpp +75 -44
  89. package/src/duckdb/src/storage/local_storage.cpp +1 -1
  90. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  91. package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
  92. package/src/duckdb/src/storage/table/row_group.cpp +11 -11
  93. package/src/duckdb/src/storage/table/scan_state.cpp +1 -1
  94. package/src/duckdb/src/storage/table/update_segment.cpp +6 -6
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev3710.0",
5
+ "version": "0.7.2-dev3763.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/database.cpp CHANGED
@@ -328,7 +328,6 @@ ScanReplacement(duckdb::ClientContext &context, const std::string &table_name, d
328
328
  children.push_back(duckdb::make_uniq<duckdb::ConstantExpression>(std::move(param)));
329
329
  }
330
330
  table_function->function = duckdb::make_uniq<duckdb::FunctionExpression>(jsargs.function, std::move(children));
331
- table_function->alias = table_name;
332
331
  return std::move(table_function);
333
332
  }
334
333
  return nullptr;
@@ -161,7 +161,7 @@ unique_ptr<FunctionData> ReadJSONBind(ClientContext &context, TableFunctionBindI
161
161
  StrpTimeFormat format;
162
162
  auto error = StrTimeFormat::ParseFormatSpecifier(format_string, format);
163
163
  if (!error.empty()) {
164
- throw InvalidInputException("read_json could not parse \"dateformat\": '%s'.", error.c_str());
164
+ throw BinderException("read_json could not parse \"dateformat\": '%s'.", error.c_str());
165
165
  }
166
166
  } else if (loption == "timestampformat" || loption == "timestamp_format") {
167
167
  auto format_string = StringValue::Get(kv.second);
@@ -173,7 +173,7 @@ unique_ptr<FunctionData> ReadJSONBind(ClientContext &context, TableFunctionBindI
173
173
  StrpTimeFormat format;
174
174
  auto error = StrTimeFormat::ParseFormatSpecifier(format_string, format);
175
175
  if (!error.empty()) {
176
- throw InvalidInputException("read_json could not parse \"timestampformat\": '%s'.", error.c_str());
176
+ throw BinderException("read_json could not parse \"timestampformat\": '%s'.", error.c_str());
177
177
  }
178
178
  } else if (loption == "records") {
179
179
  auto arg = StringValue::Get(kv.second);
@@ -184,7 +184,7 @@ unique_ptr<FunctionData> ReadJSONBind(ClientContext &context, TableFunctionBindI
184
184
  } else if (arg == "false") {
185
185
  bind_data->options.record_type = JSONRecordType::VALUES;
186
186
  } else {
187
- throw InvalidInputException("read_json requires \"records\" to be one of ['auto', 'true', 'false'].");
187
+ throw BinderException("read_json requires \"records\" to be one of ['auto', 'true', 'false'].");
188
188
  }
189
189
  }
190
190
  }
@@ -28,19 +28,23 @@ void JSONScanData::Bind(ClientContext &context, TableFunctionBindInput &input) {
28
28
  } else if (loption == "maximum_object_size") {
29
29
  maximum_object_size = MaxValue<idx_t>(UIntegerValue::Get(kv.second), maximum_object_size);
30
30
  } else if (loption == "format") {
31
- auto arg = StringValue::Get(kv.second);
32
- if (arg == "auto") {
33
- options.format = JSONFormat::AUTO_DETECT;
34
- } else if (arg == "unstructured") {
35
- options.format = JSONFormat::UNSTRUCTURED;
36
- } else if (arg == "newline_delimited" || arg == "nd") {
37
- options.format = JSONFormat::NEWLINE_DELIMITED;
38
- } else if (arg == "array") {
39
- options.format = JSONFormat::ARRAY;
40
- } else {
41
- throw InvalidInputException(
42
- "format must be one of ['auto', 'unstructured', 'newline_delimited', 'array']");
31
+ auto arg = StringUtil::Lower(StringValue::Get(kv.second));
32
+ static const auto format_options =
33
+ case_insensitive_map_t<JSONFormat> {{"auto", JSONFormat::AUTO_DETECT},
34
+ {"unstructured", JSONFormat::UNSTRUCTURED},
35
+ {"newline_delimited", JSONFormat::NEWLINE_DELIMITED},
36
+ {"nd", JSONFormat::NEWLINE_DELIMITED},
37
+ {"array", JSONFormat::ARRAY}};
38
+ auto lookup = format_options.find(arg);
39
+ if (lookup == format_options.end()) {
40
+ vector<string> valid_options;
41
+ for (auto &pair : format_options) {
42
+ valid_options.push_back(StringUtil::Format("'%s'", pair.first));
43
+ }
44
+ throw BinderException("format must be one of [%s], not '%s'", StringUtil::Join(valid_options, ", "),
45
+ arg);
43
46
  }
47
+ options.format = lookup->second;
44
48
  } else if (loption == "compression") {
45
49
  SetCompression(StringUtil::Lower(StringValue::Get(kv.second)));
46
50
  }
@@ -33,7 +33,7 @@ struct DuckDBArrowSchemaHolder {
33
33
  std::list<vector<ArrowSchema>> nested_children;
34
34
  std::list<vector<ArrowSchema *>> nested_children_ptr;
35
35
  //! This holds strings created to represent decimal types
36
- vector<unsafe_array_ptr<char>> owned_type_names;
36
+ vector<unsafe_unique_array<char>> owned_type_names;
37
37
  };
38
38
 
39
39
  static void ReleaseDuckDBArrowSchema(ArrowSchema *schema) {
@@ -131,7 +131,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
131
131
  break;
132
132
  case LogicalTypeId::TIMESTAMP_TZ: {
133
133
  string format = "tsu:" + config_timezone;
134
- auto format_ptr = make_unsafe_array<char>(format.size() + 1);
134
+ auto format_ptr = make_unsafe_uniq_array<char>(format.size() + 1);
135
135
  for (size_t i = 0; i < format.size(); i++) {
136
136
  format_ptr[i] = format[i];
137
137
  }
@@ -156,7 +156,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
156
156
  uint8_t width, scale;
157
157
  type.GetDecimalProperties(width, scale);
158
158
  string format = "d:" + to_string(width) + "," + to_string(scale);
159
- auto format_ptr = make_unsafe_array<char>(format.size() + 1);
159
+ auto format_ptr = make_unsafe_uniq_array<char>(format.size() + 1);
160
160
  for (size_t i = 0; i < format.size(); i++) {
161
161
  format_ptr[i] = format[i];
162
162
  }
@@ -204,7 +204,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
204
204
  InitializeChild(*child.children[type_idx]);
205
205
 
206
206
  auto &struct_col_name = child_types[type_idx].first;
207
- auto name_ptr = make_unsafe_array<char>(struct_col_name.size() + 1);
207
+ auto name_ptr = make_unsafe_uniq_array<char>(struct_col_name.size() + 1);
208
208
  for (size_t i = 0; i < struct_col_name.size(); i++) {
209
209
  name_ptr[i] = struct_col_name[i];
210
210
  }
@@ -19,10 +19,10 @@ void CompressedFile::Initialize(bool write) {
19
19
  this->write = write;
20
20
  stream_data.in_buf_size = compressed_fs.InBufferSize();
21
21
  stream_data.out_buf_size = compressed_fs.OutBufferSize();
22
- stream_data.in_buff = make_unsafe_array<data_t>(stream_data.in_buf_size);
22
+ stream_data.in_buff = make_unsafe_uniq_array<data_t>(stream_data.in_buf_size);
23
23
  stream_data.in_buff_start = stream_data.in_buff.get();
24
24
  stream_data.in_buff_end = stream_data.in_buff.get();
25
- stream_data.out_buff = make_unsafe_array<data_t>(stream_data.out_buf_size);
25
+ stream_data.out_buff = make_unsafe_uniq_array<data_t>(stream_data.out_buf_size);
26
26
  stream_data.out_buff_start = stream_data.out_buff.get();
27
27
  stream_data.out_buff_end = stream_data.out_buff.get();
28
28
 
@@ -87,7 +87,7 @@ idx_t FileSystem::GetAvailableMemory() {
87
87
  }
88
88
 
89
89
  string FileSystem::GetWorkingDirectory() {
90
- auto buffer = make_unsafe_array<char>(PATH_MAX);
90
+ auto buffer = make_unsafe_uniq_array<char>(PATH_MAX);
91
91
  char *ret = getcwd(buffer.get(), PATH_MAX);
92
92
  if (!ret) {
93
93
  throw IOException("Could not get working directory!");
@@ -170,7 +170,7 @@ string FileSystem::GetWorkingDirectory() {
170
170
  if (count == 0) {
171
171
  throw IOException("Could not get working directory!");
172
172
  }
173
- auto buffer = make_unsafe_array<wchar_t>(count);
173
+ auto buffer = make_unsafe_uniq_array<wchar_t>(count);
174
174
  idx_t ret = GetCurrentDirectoryW(count, buffer.get());
175
175
  if (count != ret + 1) {
176
176
  throw IOException("Could not get working directory!");
@@ -95,8 +95,8 @@ static void GatherNestedVector(Vector &rows, const SelectionVector &row_sel, Vec
95
95
  auto ptrs = FlatVector::GetData<data_ptr_t>(rows);
96
96
 
97
97
  // Build the gather locations
98
- auto data_locations = make_unsafe_array<data_ptr_t>(count);
99
- auto mask_locations = make_unsafe_array<data_ptr_t>(count);
98
+ auto data_locations = make_unsafe_uniq_array<data_ptr_t>(count);
99
+ auto mask_locations = make_unsafe_uniq_array<data_ptr_t>(count);
100
100
  for (idx_t i = 0; i < count; i++) {
101
101
  auto row_idx = row_sel.get_index(i);
102
102
  auto row = ptrs[row_idx];
@@ -123,7 +123,7 @@ string BinaryDeserializer::ReadString() {
123
123
  if (size == 0) {
124
124
  return string();
125
125
  }
126
- auto buffer = make_unsafe_array<data_t>(size);
126
+ auto buffer = make_unsafe_uniq_array<data_t>(size);
127
127
  ReadData(buffer.get(), size);
128
128
  return string((char *)buffer.get(), size);
129
129
  }
@@ -9,7 +9,7 @@ namespace duckdb {
9
9
 
10
10
  BufferedFileReader::BufferedFileReader(FileSystem &fs, const char *path, optional_ptr<ClientContext> context,
11
11
  FileLockType lock_type, optional_ptr<FileOpener> opener)
12
- : fs(fs), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), read_data(0), total_read(0),
12
+ : fs(fs), data(make_unsafe_uniq_array<data_t>(FILE_BUFFER_SIZE)), offset(0), read_data(0), total_read(0),
13
13
  context(context) {
14
14
  handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ, lock_type, FileSystem::DEFAULT_COMPRESSION, opener.get());
15
15
  file_size = fs.GetFileSize(*handle);
@@ -9,7 +9,7 @@ namespace duckdb {
9
9
  constexpr uint8_t BufferedFileWriter::DEFAULT_OPEN_FLAGS;
10
10
 
11
11
  BufferedFileWriter::BufferedFileWriter(FileSystem &fs, const string &path_p, uint8_t open_flags)
12
- : fs(fs), path(path_p), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), total_written(0) {
12
+ : fs(fs), path(path_p), data(make_unsafe_uniq_array<data_t>(FILE_BUFFER_SIZE)), offset(0), total_written(0) {
13
13
  handle = fs.OpenFile(path, open_flags, FileLockType::WRITE_LOCK);
14
14
  }
15
15
 
@@ -5,10 +5,10 @@
5
5
  namespace duckdb {
6
6
 
7
7
  BufferedSerializer::BufferedSerializer(idx_t maximum_size)
8
- : BufferedSerializer(make_unsafe_array<data_t>(maximum_size), maximum_size) {
8
+ : BufferedSerializer(make_unsafe_uniq_array<data_t>(maximum_size), maximum_size) {
9
9
  }
10
10
 
11
- BufferedSerializer::BufferedSerializer(unsafe_array_ptr<data_t> data, idx_t size)
11
+ BufferedSerializer::BufferedSerializer(unsafe_unique_array<data_t> data, idx_t size)
12
12
  : maximum_size(size), data(data.get()) {
13
13
  blob.size = 0;
14
14
  blob.data = std::move(data);
@@ -26,7 +26,7 @@ void BufferedSerializer::WriteData(const_data_ptr_t buffer, idx_t write_size) {
26
26
  auto new_data = new data_t[maximum_size];
27
27
  memcpy(new_data, data, blob.size);
28
28
  data = new_data;
29
- blob.data = unsafe_array_ptr<data_t>(new_data);
29
+ blob.data = unsafe_unique_array<data_t>(new_data);
30
30
  }
31
31
 
32
32
  memcpy(data + blob.size, buffer, write_size);
@@ -8,7 +8,7 @@ string Deserializer::Read() {
8
8
  if (size == 0) {
9
9
  return string();
10
10
  }
11
- auto buffer = make_unsafe_array<data_t>(size);
11
+ auto buffer = make_unsafe_uniq_array<data_t>(size);
12
12
  ReadData(buffer.get(), size);
13
13
  return string((char *)buffer.get(), size);
14
14
  }
@@ -17,7 +17,7 @@ static void SortTiedBlobs(BufferManager &buffer_manager, const data_ptr_t datapt
17
17
  return;
18
18
  }
19
19
  // Fill pointer array for sorting
20
- auto ptr_block = make_unsafe_array<data_ptr_t>(end - start);
20
+ auto ptr_block = make_unsafe_uniq_array<data_ptr_t>(end - start);
21
21
  auto entry_ptrs = (data_ptr_t *)ptr_block.get();
22
22
  for (idx_t i = start; i < end; i++) {
23
23
  entry_ptrs[i - start] = row_ptr;
@@ -158,7 +158,7 @@ inline void InsertionSort(const data_ptr_t orig_ptr, const data_ptr_t temp_ptr,
158
158
  const data_ptr_t target_ptr = swap ? orig_ptr : temp_ptr;
159
159
  if (count > 1) {
160
160
  const idx_t total_offset = col_offset + offset;
161
- auto temp_val = make_unsafe_array<data_t>(row_width);
161
+ auto temp_val = make_unsafe_uniq_array<data_t>(row_width);
162
162
  const data_ptr_t val = temp_val.get();
163
163
  const auto comp_width = total_comp_width - offset;
164
164
  for (idx_t i = 1; i < count; i++) {
@@ -249,7 +249,7 @@ void RadixSort(BufferManager &buffer_manager, const data_ptr_t &dataptr, const i
249
249
  RadixSortLSD(buffer_manager, dataptr, count, col_offset, sort_layout.entry_size, sorting_size);
250
250
  } else {
251
251
  auto temp_block = buffer_manager.Allocate(MaxValue(count * sort_layout.entry_size, (idx_t)Storage::BLOCK_SIZE));
252
- auto preallocated_array = make_unsafe_array<idx_t>(sorting_size * SortConstants::MSD_RADIX_LOCATIONS);
252
+ auto preallocated_array = make_unsafe_uniq_array<idx_t>(sorting_size * SortConstants::MSD_RADIX_LOCATIONS);
253
253
  RadixSortMSD(dataptr, temp_block.Ptr(), count, col_offset, sort_layout.entry_size, sorting_size, 0,
254
254
  preallocated_array.get(), false);
255
255
  }
@@ -291,7 +291,7 @@ void LocalSortState::SortInMemory() {
291
291
  // Radix sort and break ties until no more ties, or until all columns are sorted
292
292
  idx_t sorting_size = 0;
293
293
  idx_t col_offset = 0;
294
- unsafe_array_ptr<bool> ties_ptr;
294
+ unsafe_unique_array<bool> ties_ptr;
295
295
  bool *ties = nullptr;
296
296
  bool contains_string = false;
297
297
  for (idx_t i = 0; i < sort_layout->column_count; i++) {
@@ -305,7 +305,7 @@ void LocalSortState::SortInMemory() {
305
305
  if (!ties) {
306
306
  // This is the first sort
307
307
  RadixSort(*buffer_manager, dataptr, count, col_offset, sorting_size, *sort_layout, contains_string);
308
- ties_ptr = make_unsafe_array<bool>(count);
308
+ ties_ptr = make_unsafe_uniq_array<bool>(count);
309
309
  ties = ties_ptr.get();
310
310
  std::fill_n(ties, count - 1, true);
311
311
  ties[count - 1] = false;
@@ -193,6 +193,10 @@ string StringUtil::Lower(const string &str) {
193
193
  return (copy);
194
194
  }
195
195
 
196
+ bool StringUtil::IsLower(const string &str) {
197
+ return str == Lower(str);
198
+ }
199
+
196
200
  // Jenkins hash function: https://en.wikipedia.org/wiki/Jenkins_hash_function
197
201
  uint64_t StringUtil::CIHash(const string &str) {
198
202
  uint32_t hash = 0;
@@ -277,7 +281,7 @@ vector<string> StringUtil::TopNStrings(vector<pair<string, idx_t>> scores, idx_t
277
281
 
278
282
  struct LevenshteinArray {
279
283
  LevenshteinArray(idx_t len1, idx_t len2) : len1(len1) {
280
- dist = make_unsafe_array<idx_t>(len1 * len2);
284
+ dist = make_unsafe_uniq_array<idx_t>(len1 * len2);
281
285
  }
282
286
 
283
287
  idx_t &Score(idx_t i, idx_t j) {
@@ -286,7 +290,7 @@ struct LevenshteinArray {
286
290
 
287
291
  private:
288
292
  idx_t len1;
289
- unsafe_array_ptr<idx_t> dist;
293
+ unsafe_unique_array<idx_t> dist;
290
294
 
291
295
  idx_t GetIndex(idx_t i, idx_t j) {
292
296
  return j * len1 + i;
@@ -78,7 +78,7 @@ void Bit::ToString(string_t bits, char *output) {
78
78
 
79
79
  string Bit::ToString(string_t str) {
80
80
  auto len = BitLength(str);
81
- auto buffer = make_unsafe_array<char>(len);
81
+ auto buffer = make_unsafe_uniq_array<char>(len);
82
82
  ToString(str, buffer.get());
83
83
  return string(buffer.get(), len);
84
84
  }
@@ -140,7 +140,7 @@ void Bit::ToBit(string_t str, string_t &output_str) {
140
140
 
141
141
  string Bit::ToBit(string_t str) {
142
142
  auto bit_len = GetBitSize(str);
143
- auto buffer = make_unsafe_array<char>(bit_len);
143
+ auto buffer = make_unsafe_uniq_array<char>(bit_len);
144
144
  string_t output_str(buffer.get(), bit_len);
145
145
  Bit::ToBit(str, output_str);
146
146
  return output_str.GetString();
@@ -64,7 +64,7 @@ void Blob::ToString(string_t blob, char *output) {
64
64
 
65
65
  string Blob::ToString(string_t blob) {
66
66
  auto str_len = GetStringSize(blob);
67
- auto buffer = make_unsafe_array<char>(str_len);
67
+ auto buffer = make_unsafe_uniq_array<char>(str_len);
68
68
  Blob::ToString(blob, buffer.get());
69
69
  return string(buffer.get(), str_len);
70
70
  }
@@ -136,7 +136,7 @@ void Blob::ToBlob(string_t str, data_ptr_t output) {
136
136
 
137
137
  string Blob::ToBlob(string_t str) {
138
138
  auto blob_len = GetBlobSize(str);
139
- auto buffer = make_unsafe_array<char>(blob_len);
139
+ auto buffer = make_unsafe_uniq_array<char>(blob_len);
140
140
  Blob::ToBlob(str, (data_ptr_t)buffer.get());
141
141
  return string(buffer.get(), blob_len);
142
142
  }
@@ -291,8 +291,8 @@ void DataChunk::Slice(DataChunk &other, const SelectionVector &sel, idx_t count_
291
291
  }
292
292
  }
293
293
 
294
- unsafe_array_ptr<UnifiedVectorFormat> DataChunk::ToUnifiedFormat() {
295
- auto orrified_data = make_unsafe_array<UnifiedVectorFormat>(ColumnCount());
294
+ unsafe_unique_array<UnifiedVectorFormat> DataChunk::ToUnifiedFormat() {
295
+ auto orrified_data = make_unsafe_uniq_array<UnifiedVectorFormat>(ColumnCount());
296
296
  for (idx_t col_idx = 0; col_idx < ColumnCount(); col_idx++) {
297
297
  data[col_idx].ToUnifiedFormat(size(), orrified_data[col_idx]);
298
298
  }
@@ -362,7 +362,7 @@ string Date::ToString(date_t date) {
362
362
  Date::Convert(date, date_units[0], date_units[1], date_units[2]);
363
363
 
364
364
  auto length = DateToStringCast::Length(date_units, year_length, add_bc);
365
- auto buffer = make_unsafe_array<char>(length);
365
+ auto buffer = make_unsafe_uniq_array<char>(length);
366
366
  DateToStringCast::Format(buffer.get(), date_units, year_length, add_bc);
367
367
  return string(buffer.get(), length);
368
368
  }
@@ -6,7 +6,7 @@ namespace duckdb {
6
6
  template <class SIGNED, class UNSIGNED>
7
7
  string TemplatedDecimalToString(SIGNED value, uint8_t width, uint8_t scale) {
8
8
  auto len = DecimalToString::DecimalLength<SIGNED, UNSIGNED>(value, width, scale);
9
- auto data = make_unsafe_array<char>(len + 1);
9
+ auto data = make_unsafe_uniq_array<char>(len + 1);
10
10
  DecimalToString::FormatDecimal<SIGNED, UNSIGNED>(value, width, scale, data.get(), len);
11
11
  return string(data.get(), len);
12
12
  }
@@ -25,7 +25,7 @@ string Decimal::ToString(int64_t value, uint8_t width, uint8_t scale) {
25
25
 
26
26
  string Decimal::ToString(hugeint_t value, uint8_t width, uint8_t scale) {
27
27
  auto len = HugeintToStringCast::DecimalLength(value, width, scale);
28
- auto data = make_unsafe_array<char>(len + 1);
28
+ auto data = make_unsafe_uniq_array<char>(len + 1);
29
29
  HugeintToStringCast::FormatDecimal(value, width, scale, data.get(), len);
30
30
  return string(data.get(), len);
31
31
  }
@@ -5,7 +5,7 @@
5
5
  namespace duckdb {
6
6
 
7
7
  SelectionData::SelectionData(idx_t count) {
8
- owned_data = make_unsafe_array<sel_t>(count);
8
+ owned_data = make_unsafe_uniq_array<sel_t>(count);
9
9
  #ifdef DEBUG
10
10
  for (idx_t i = 0; i < count; i++) {
11
11
  owned_data[i] = std::numeric_limits<sel_t>::max();
@@ -158,7 +158,7 @@ string Time::ToString(dtime_t time) {
158
158
 
159
159
  char micro_buffer[6];
160
160
  auto length = TimeToStringCast::Length(time_units, micro_buffer);
161
- auto buffer = make_unsafe_array<char>(length);
161
+ auto buffer = make_unsafe_uniq_array<char>(length);
162
162
  TimeToStringCast::Format(buffer.get(), length, time_units, micro_buffer);
163
163
  return string(buffer.get(), length);
164
164
  }
@@ -297,7 +297,7 @@ void Vector::Resize(idx_t cur_size, idx_t new_size) {
297
297
  }
298
298
  for (auto &data_to_resize : to_resize) {
299
299
  if (!data_to_resize.is_nested) {
300
- auto new_data = make_unsafe_array<data_t>(new_size * data_to_resize.type_size);
300
+ auto new_data = make_unsafe_uniq_array<data_t>(new_size * data_to_resize.type_size);
301
301
  memcpy(new_data.get(), data_to_resize.data, cur_size * data_to_resize.type_size * sizeof(data_t));
302
302
  data_to_resize.buffer->SetData(std::move(new_data));
303
303
  data_to_resize.vec.data = data_to_resize.buffer->GetData();
@@ -920,7 +920,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
920
920
  if (TypeIsConstantSize(type.InternalType())) {
921
921
  // constant size type: simple copy
922
922
  idx_t write_size = GetTypeIdSize(type.InternalType()) * count;
923
- auto ptr = make_unsafe_array<data_t>(write_size);
923
+ auto ptr = make_unsafe_uniq_array<data_t>(write_size);
924
924
  VectorOperations::WriteToStorage(*this, count, ptr.get());
925
925
  serializer.WriteData(ptr.get(), write_size);
926
926
  } else {
@@ -947,7 +947,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
947
947
  auto list_size = ListVector::GetListSize(*this);
948
948
 
949
949
  // serialize the list entries in a flat array
950
- auto data = make_unsafe_array<list_entry_t>(count);
950
+ auto data = make_unsafe_uniq_array<list_entry_t>(count);
951
951
  auto source_array = (list_entry_t *)vdata.data;
952
952
  for (idx_t i = 0; i < count; i++) {
953
953
  auto idx = vdata.sel->get_index(i);
@@ -988,7 +988,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
988
988
  if (TypeIsConstantSize(logical_type.InternalType())) {
989
989
  // constant size type: simple copy
990
990
  idx_t write_size = GetTypeIdSize(logical_type.InternalType()) * count;
991
- auto ptr = make_unsafe_array<data_t>(write_size);
991
+ auto ptr = make_unsafe_uniq_array<data_t>(write_size);
992
992
  VectorOperations::WriteToStorage(*this, count, ptr.get());
993
993
  serializer.WriteProperty("data", ptr.get(), write_size);
994
994
  } else {
@@ -1027,7 +1027,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
1027
1027
  auto list_size = ListVector::GetListSize(*this);
1028
1028
 
1029
1029
  // serialize the list entries in a flat array
1030
- auto entries = make_unsafe_array<list_entry_t>(count);
1030
+ auto entries = make_unsafe_uniq_array<list_entry_t>(count);
1031
1031
  auto source_array = (list_entry_t *)vdata.data;
1032
1032
  for (idx_t i = 0; i < count; i++) {
1033
1033
  auto idx = vdata.sel->get_index(i);
@@ -1071,7 +1071,7 @@ void Vector::FormatDeserialize(FormatDeserializer &deserializer, idx_t count) {
1071
1071
  if (TypeIsConstantSize(logical_type.InternalType())) {
1072
1072
  // constant size type: read fixed amount of data
1073
1073
  auto column_size = GetTypeIdSize(logical_type.InternalType()) * count;
1074
- auto ptr = make_unsafe_array<data_t>(column_size);
1074
+ auto ptr = make_unsafe_uniq_array<data_t>(column_size);
1075
1075
  deserializer.ReadProperty("data", ptr.get(), column_size);
1076
1076
 
1077
1077
  VectorOperations::ReadFromStorage(ptr.get(), count, *this);
@@ -1158,7 +1158,7 @@ void Vector::Deserialize(idx_t count, Deserializer &source) {
1158
1158
  if (TypeIsConstantSize(type.InternalType())) {
1159
1159
  // constant size type: read fixed amount of data from
1160
1160
  auto column_size = GetTypeIdSize(type.InternalType()) * count;
1161
- auto ptr = make_unsafe_array<data_t>(column_size);
1161
+ auto ptr = make_unsafe_uniq_array<data_t>(column_size);
1162
1162
  source.ReadData(ptr.get(), column_size);
1163
1163
 
1164
1164
  VectorOperations::ReadFromStorage(ptr.get(), count, *this);
@@ -11,7 +11,7 @@ std::wstring WindowsUtil::UTF8ToUnicode(const char *input) {
11
11
  if (result_size == 0) {
12
12
  throw IOException("Failure in MultiByteToWideChar");
13
13
  }
14
- auto buffer = make_unsafe_array<wchar_t>(result_size);
14
+ auto buffer = make_unsafe_uniq_array<wchar_t>(result_size);
15
15
  result_size = MultiByteToWideChar(CP_UTF8, 0, input, -1, buffer.get(), result_size);
16
16
  if (result_size == 0) {
17
17
  throw IOException("Failure in MultiByteToWideChar");
@@ -26,7 +26,7 @@ static string WideCharToMultiByteWrapper(LPCWSTR input, uint32_t code_page) {
26
26
  if (result_size == 0) {
27
27
  throw IOException("Failure in WideCharToMultiByte");
28
28
  }
29
- auto buffer = make_unsafe_array<char>(result_size);
29
+ auto buffer = make_unsafe_uniq_array<char>(result_size);
30
30
  result_size = WideCharToMultiByte(code_page, 0, input, -1, buffer.get(), result_size, 0, 0);
31
31
  if (result_size == 0) {
32
32
  throw IOException("Failure in WideCharToMultiByte");
@@ -179,7 +179,7 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
179
179
 
180
180
  // state_buffer holds the state for each list of this chunk
181
181
  idx_t size = aggr.function.state_size();
182
- auto state_buffer = make_unsafe_array<data_t>(size * count);
182
+ auto state_buffer = make_unsafe_uniq_array<data_t>(size * count);
183
183
 
184
184
  // state vector for initialize and finalize
185
185
  StateVector state_vector(count, info.aggr_expr->Copy());
@@ -94,7 +94,7 @@ static void PrintfFunction(DataChunk &args, ExpressionState &state, Vector &resu
94
94
 
95
95
  // now gather all the format arguments
96
96
  vector<duckdb_fmt::basic_format_arg<CTX>> format_args;
97
- vector<unsafe_array_ptr<data_t>> string_args;
97
+ vector<unsafe_unique_array<data_t>> string_args;
98
98
 
99
99
  for (idx_t col_idx = 1; col_idx < args.ColumnCount(); col_idx++) {
100
100
  auto &col = args.data[col_idx];
@@ -390,7 +390,7 @@ idx_t GroupedAggregateHashTable::FindOrCreateGroupsInternal(AggregateHTAppendSta
390
390
  }
391
391
  TupleDataCollection::ToUnifiedFormat(state.chunk_state, state.group_chunk);
392
392
  if (!state.group_data) {
393
- state.group_data = make_unsafe_array<UnifiedVectorFormat>(state.group_chunk.ColumnCount());
393
+ state.group_data = make_unsafe_uniq_array<UnifiedVectorFormat>(state.group_chunk.ColumnCount());
394
394
  }
395
395
  TupleDataCollection::GetVectorData(state.chunk_state, state.group_data.get());
396
396
 
@@ -142,7 +142,7 @@ static idx_t FilterNullValues(UnifiedVectorFormat &vdata, const SelectionVector
142
142
  return result_count;
143
143
  }
144
144
 
145
- idx_t JoinHashTable::PrepareKeys(DataChunk &keys, unsafe_array_ptr<UnifiedVectorFormat> &key_data,
145
+ idx_t JoinHashTable::PrepareKeys(DataChunk &keys, unsafe_unique_array<UnifiedVectorFormat> &key_data,
146
146
  const SelectionVector *&current_sel, SelectionVector &sel, bool build_side) {
147
147
  key_data = keys.ToUnifiedFormat();
148
148
 
@@ -197,7 +197,7 @@ void JoinHashTable::Build(PartitionedTupleDataAppendState &append_state, DataChu
197
197
  }
198
198
 
199
199
  // prepare the keys for processing
200
- unsafe_array_ptr<UnifiedVectorFormat> key_data;
200
+ unsafe_unique_array<UnifiedVectorFormat> key_data;
201
201
  const SelectionVector *current_sel;
202
202
  SelectionVector sel(STANDARD_VECTOR_SIZE);
203
203
  idx_t added_count = PrepareKeys(keys, key_data, current_sel, sel, true);
@@ -332,7 +332,7 @@ unique_ptr<ScanStructure> JoinHashTable::InitializeScanStructure(DataChunk &keys
332
332
  auto ss = make_uniq<ScanStructure>(*this);
333
333
 
334
334
  if (join_type != JoinType::INNER) {
335
- ss->found_match = make_unsafe_array<bool>(STANDARD_VECTOR_SIZE);
335
+ ss->found_match = make_unsafe_uniq_array<bool>(STANDARD_VECTOR_SIZE);
336
336
  memset(ss->found_match.get(), 0, sizeof(bool) * STANDARD_VECTOR_SIZE);
337
337
  }
338
338
 
@@ -39,7 +39,7 @@ struct AggregateState {
39
39
  for (auto &aggregate : aggregate_expressions) {
40
40
  D_ASSERT(aggregate->GetExpressionClass() == ExpressionClass::BOUND_AGGREGATE);
41
41
  auto &aggr = aggregate->Cast<BoundAggregateExpression>();
42
- auto state = make_unsafe_array<data_t>(aggr.function.state_size());
42
+ auto state = make_unsafe_uniq_array<data_t>(aggr.function.state_size());
43
43
  aggr.function.initialize(state.get());
44
44
  aggregates.push_back(std::move(state));
45
45
  bind_data.push_back(aggr.bind_info.get());
@@ -69,7 +69,7 @@ struct AggregateState {
69
69
  }
70
70
 
71
71
  //! The aggregate values
72
- vector<unsafe_array_ptr<data_t>> aggregates;
72
+ vector<unsafe_unique_array<data_t>> aggregates;
73
73
  //! The bind data
74
74
  vector<FunctionData *> bind_data;
75
75
  //! The destructors
@@ -10,7 +10,7 @@ void OuterJoinMarker::Initialize(idx_t count_p) {
10
10
  return;
11
11
  }
12
12
  this->count = count_p;
13
- found_match = make_unsafe_array<bool>(count);
13
+ found_match = make_unsafe_uniq_array<bool>(count);
14
14
  Reset();
15
15
  }
16
16
 
@@ -25,7 +25,7 @@ bool PerfectHashJoinExecutor::BuildPerfectHashTable(LogicalType &key_type) {
25
25
  }
26
26
 
27
27
  // and for duplicate_checking
28
- bitmap_build_idx = make_unsafe_array<bool>(build_size);
28
+ bitmap_build_idx = make_unsafe_uniq_array<bool>(build_size);
29
29
  memset(bitmap_build_idx.get(), 0, sizeof(bool) * build_size); // set false
30
30
 
31
31
  // Now fill columns with build data
@@ -72,7 +72,7 @@ void PhysicalRangeJoin::GlobalSortedTable::Combine(LocalSortedTable &ltable) {
72
72
  }
73
73
 
74
74
  void PhysicalRangeJoin::GlobalSortedTable::IntializeMatches() {
75
- found_match = make_unsafe_array<bool>(Count());
75
+ found_match = make_unsafe_uniq_array<bool>(Count());
76
76
  memset(found_match.get(), 0, sizeof(bool) * Count());
77
77
  }
78
78
 
@@ -1425,7 +1425,7 @@ bool BufferedCSVReader::ReadBuffer(idx_t &start, idx_t &line_start) {
1425
1425
  GetLineNumberStr(linenr, linenr_estimated));
1426
1426
  }
1427
1427
 
1428
- buffer = make_unsafe_array<char>(buffer_read_size + remaining + 1);
1428
+ buffer = make_unsafe_uniq_array<char>(buffer_read_size + remaining + 1);
1429
1429
  buffer_size = remaining + buffer_read_size;
1430
1430
  if (remaining > 0) {
1431
1431
  // remaining from last buffer: copy it here