duckdb 0.4.1-dev953.0 → 0.4.1-dev960.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.4.1-dev953.0",
4
+ "version": "0.4.1-dev960.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/database.cpp CHANGED
@@ -1,4 +1,5 @@
1
1
  #include "duckdb_node.hpp"
2
+ #include "napi.h"
2
3
  #include "parquet-amalgamation.hpp"
3
4
 
4
5
  namespace node_duckdb {
@@ -86,7 +87,8 @@ struct OpenTask : public Task {
86
87
  bool success = false;
87
88
  };
88
89
 
89
- Database::Database(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Database>(info), task_inflight(false) {
90
+ Database::Database(const Napi::CallbackInfo &info)
91
+ : Napi::ObjectWrap<Database>(info), task_inflight(false), env(info.Env()) {
90
92
  auto env = info.Env();
91
93
 
92
94
  if (info.Length() < 1 || !info[0].IsString()) {
@@ -119,6 +121,10 @@ Database::Database(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Database>(
119
121
  Schedule(env, duckdb::make_unique<OpenTask>(*this, filename, access_mode, config, callback));
120
122
  }
121
123
 
124
+ Database::~Database() {
125
+ Napi::MemoryManagement::AdjustExternalMemory(env, -bytes_allocated);
126
+ }
127
+
122
128
  void Database::Schedule(Napi::Env env, std::unique_ptr<Task> task) {
123
129
  {
124
130
  std::lock_guard<std::mutex> lock(task_mutex);
@@ -146,6 +152,16 @@ void Database::TaskComplete(Napi::Env env) {
146
152
  task_inflight = false;
147
153
  }
148
154
  Process(env);
155
+
156
+ if (database) {
157
+ // Bookkeeping: tell node (and the node GC in particular) how much
158
+ // memory we're using, such that it can make better decisions on when to
159
+ // trigger collections.
160
+ auto &buffer_manager = duckdb::BufferManager::GetBufferManager(*database->instance);
161
+ auto current_bytes = buffer_manager.GetUsedMemory();
162
+ Napi::MemoryManagement::AdjustExternalMemory(env, current_bytes - bytes_allocated);
163
+ bytes_allocated = current_bytes;
164
+ }
149
165
  }
150
166
 
151
167
  void Database::Process(Napi::Env env) {
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 "0bcc23216"
15
- #define DUCKDB_VERSION "v0.4.1-dev953"
14
+ #define DUCKDB_SOURCE_ID "ffd18c1e7"
15
+ #define DUCKDB_VERSION "v0.4.1-dev960"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -5099,9 +5099,19 @@ public:
5099
5099
  auto rdata = FlatVector::GetData<RIGHT_TYPE>(right);
5100
5100
 
5101
5101
  if (LEFT_CONSTANT && ConstantVector::IsNull(left)) {
5102
+ if (false_sel) {
5103
+ for (idx_t i = 0; i < count; i++) {
5104
+ false_sel->set_index(i, sel->get_index(i));
5105
+ }
5106
+ }
5102
5107
  return 0;
5103
5108
  }
5104
5109
  if (RIGHT_CONSTANT && ConstantVector::IsNull(right)) {
5110
+ if (false_sel) {
5111
+ for (idx_t i = 0; i < count; i++) {
5112
+ false_sel->set_index(i, sel->get_index(i));
5113
+ }
5114
+ }
5105
5115
  return 0;
5106
5116
  }
5107
5117
 
@@ -41,6 +41,7 @@ class Connection;
41
41
  class Database : public Napi::ObjectWrap<Database> {
42
42
  public:
43
43
  explicit Database(const Napi::CallbackInfo &info);
44
+ ~Database() override;
44
45
  static Napi::Object Init(Napi::Env env, Napi::Object exports);
45
46
  void Process(Napi::Env env);
46
47
  void TaskComplete(Napi::Env env);
@@ -76,6 +77,8 @@ private:
76
77
  std::mutex task_mutex;
77
78
  bool task_inflight;
78
79
  static Napi::FunctionReference constructor;
80
+ Napi::Env env;
81
+ int64_t bytes_allocated = 0;
79
82
  };
80
83
 
81
84
  struct JSArgs;