duckdb 0.3.5-dev705.0 → 0.3.5-dev725.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.5-dev705.0",
4
+ "version": "0.3.5-dev725.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -45325,7 +45325,7 @@ void Vector::Initialize(bool zero_data, idx_t capacity) {
45325
45325
  auto struct_buffer = make_unique<VectorStructBuffer>(type, capacity);
45326
45326
  auxiliary = move(struct_buffer);
45327
45327
  } else if (internal_type == PhysicalType::LIST) {
45328
- auto list_buffer = make_unique<VectorListBuffer>(type);
45328
+ auto list_buffer = make_unique<VectorListBuffer>(type, capacity);
45329
45329
  auxiliary = move(list_buffer);
45330
45330
  }
45331
45331
  auto type_size = GetTypeIdSize(internal_type);
@@ -46675,18 +46675,14 @@ VectorListBuffer::VectorListBuffer(unique_ptr<Vector> vector, idx_t initial_capa
46675
46675
  }
46676
46676
 
46677
46677
  VectorListBuffer::VectorListBuffer(const LogicalType &list_type, idx_t initial_capacity)
46678
- : VectorBuffer(VectorBufferType::LIST_BUFFER) {
46679
- // FIXME: directly construct vector of correct size
46680
- child = make_unique<Vector>(ListType::GetChildType(list_type));
46681
- capacity = STANDARD_VECTOR_SIZE;
46682
- Reserve(initial_capacity);
46678
+ : VectorBuffer(VectorBufferType::LIST_BUFFER), capacity(initial_capacity),
46679
+ child(make_unique<Vector>(ListType::GetChildType(list_type), initial_capacity)) {
46683
46680
  }
46684
46681
 
46685
46682
  void VectorListBuffer::Reserve(idx_t to_reserve) {
46686
46683
  if (to_reserve > capacity) {
46687
- idx_t new_capacity = (to_reserve + STANDARD_VECTOR_SIZE - 1) / STANDARD_VECTOR_SIZE * STANDARD_VECTOR_SIZE;
46684
+ idx_t new_capacity = NextPowerOfTwo(to_reserve);
46688
46685
  D_ASSERT(new_capacity >= to_reserve);
46689
- D_ASSERT(new_capacity % STANDARD_VECTOR_SIZE == 0);
46690
46686
  child->Resize(capacity, new_capacity);
46691
46687
  capacity = new_capacity;
46692
46688
  }
@@ -85972,7 +85968,9 @@ static void ListUpdateFunction(Vector inputs[], FunctionData *, idx_t input_coun
85972
85968
  for (idx_t i = 0; i < count; i++) {
85973
85969
  auto state = states[sdata.sel->get_index(i)];
85974
85970
  if (!state->list_vector) {
85975
- state->list_vector = new Vector(list_vector_type);
85971
+ // NOTE: any number bigger than 1 can cause DuckDB to run out of memory for specific queries
85972
+ // consisting of millions of groups in the group by and complex (nested) vectors
85973
+ state->list_vector = new Vector(list_vector_type, 1);
85976
85974
  }
85977
85975
  ListVector::Append(*state->list_vector, input, i + 1, i);
85978
85976
  }
@@ -85991,7 +85989,10 @@ static void ListCombineFunction(Vector &state, Vector &combined, FunctionData *b
85991
85989
  continue;
85992
85990
  }
85993
85991
  if (!combined_ptr[i]->list_vector) {
85994
- combined_ptr[i]->list_vector = new Vector(state->list_vector->GetType());
85992
+ // NOTE: initializing this with a capacity of ListVector::GetListSize(*state->list_vector) causes
85993
+ // DuckDB to run out of memory for multiple threads with millions of groups in the group by and complex
85994
+ // (nested) vectors
85995
+ combined_ptr[i]->list_vector = new Vector(state->list_vector->GetType(), 1);
85995
85996
  }
85996
85997
  ListVector::Append(*combined_ptr[i]->list_vector, ListVector::GetEntry(*state->list_vector),
85997
85998
  ListVector::GetListSize(*state->list_vector));
@@ -86006,6 +86007,7 @@ static void ListFinalize(Vector &state_vector, FunctionData *, Vector &result, i
86006
86007
  D_ASSERT(result.GetType().id() == LogicalTypeId::LIST);
86007
86008
 
86008
86009
  auto &mask = FlatVector::Validity(result);
86010
+ auto list_struct_data = FlatVector::GetData<list_entry_t>(result);
86009
86011
  size_t total_len = ListVector::GetListSize(result);
86010
86012
 
86011
86013
  for (idx_t i = 0; i < count; i++) {
@@ -86016,22 +86018,14 @@ static void ListFinalize(Vector &state_vector, FunctionData *, Vector &result, i
86016
86018
  continue;
86017
86019
  }
86018
86020
 
86019
- auto list_struct_data = FlatVector::GetData<list_entry_t>(result);
86020
86021
  auto &state_lv = *state->list_vector;
86021
86022
  auto state_lv_count = ListVector::GetListSize(state_lv);
86022
86023
  list_struct_data[rid].length = state_lv_count;
86023
86024
  list_struct_data[rid].offset = total_len;
86024
86025
  total_len += state_lv_count;
86025
- }
86026
86026
 
86027
- for (idx_t i = 0; i < count; i++) {
86028
- auto state = states[sdata.sel->get_index(i)];
86029
- if (!state->list_vector) {
86030
- continue;
86031
- }
86032
- auto &list_vec = *state->list_vector;
86033
- auto &list_vec_to_append = ListVector::GetEntry(list_vec);
86034
- ListVector::Append(result, list_vec_to_append, ListVector::GetListSize(list_vec));
86027
+ auto &list_vec_to_append = ListVector::GetEntry(state_lv);
86028
+ ListVector::Append(result, list_vec_to_append, state_lv_count);
86035
86029
  }
86036
86030
  }
86037
86031
 
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "d7fb3035e"
15
- #define DUCKDB_VERSION "v0.3.5-dev705"
14
+ #define DUCKDB_SOURCE_ID "463e45ba9"
15
+ #define DUCKDB_VERSION "v0.3.5-dev725"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //