duckdb 0.3.5-dev992.0 → 0.4.1-dev1019.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/Makefile +2 -2
- package/binding.gyp +8 -5
- package/lib/duckdb.js +92 -64
- package/package.json +1 -1
- package/src/connection.cpp +109 -130
- package/src/data_chunk.cpp +185 -0
- package/src/database.cpp +64 -12
- package/src/duckdb.cpp +58294 -25711
- package/src/duckdb.hpp +4178 -2318
- package/src/duckdb_node.hpp +23 -17
- package/src/parquet-amalgamation.cpp +37289 -36547
- package/src/parquet-amalgamation.hpp +281 -120
- package/src/statement.cpp +17 -12
- package/test/extension.test.js +1 -1
- package/test/pathnames.test.js +82 -0
- package/test/syntax_error.test.js +16 -0
- package/test/udf.test.js +172 -107
package/src/duckdb_node.hpp
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
#define NODE_ADDON_API_DISABLE_DEPRECATED
|
|
3
|
+
#include "duckdb.hpp"
|
|
4
|
+
|
|
3
5
|
#include <napi.h>
|
|
4
6
|
#include <queue>
|
|
5
7
|
#include <unordered_map>
|
|
6
8
|
|
|
7
|
-
#include "duckdb.hpp"
|
|
8
|
-
|
|
9
9
|
namespace node_duckdb {
|
|
10
10
|
|
|
11
11
|
struct Task {
|
|
12
|
-
Task(Napi::Reference<Napi::Object> &
|
|
13
|
-
if (!
|
|
14
|
-
callback = Persistent(
|
|
12
|
+
Task(Napi::Reference<Napi::Object> &object, Napi::Function cb) : object(object) {
|
|
13
|
+
if (!cb.IsUndefined() && cb.IsFunction()) {
|
|
14
|
+
callback = Persistent(cb); // TODO not sure what this does
|
|
15
15
|
}
|
|
16
16
|
object.Ref();
|
|
17
17
|
}
|
|
@@ -40,7 +40,8 @@ class Connection;
|
|
|
40
40
|
|
|
41
41
|
class Database : public Napi::ObjectWrap<Database> {
|
|
42
42
|
public:
|
|
43
|
-
Database(const Napi::CallbackInfo &info);
|
|
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);
|
|
@@ -50,8 +51,9 @@ public:
|
|
|
50
51
|
static bool HasInstance(Napi::Value val) {
|
|
51
52
|
Napi::Env env = val.Env();
|
|
52
53
|
Napi::HandleScope scope(env);
|
|
53
|
-
if (!val.IsObject())
|
|
54
|
+
if (!val.IsObject()) {
|
|
54
55
|
return false;
|
|
56
|
+
}
|
|
55
57
|
Napi::Object obj = val.As<Napi::Object>();
|
|
56
58
|
return obj.InstanceOf(constructor.Value());
|
|
57
59
|
}
|
|
@@ -75,17 +77,19 @@ private:
|
|
|
75
77
|
std::mutex task_mutex;
|
|
76
78
|
bool task_inflight;
|
|
77
79
|
static Napi::FunctionReference constructor;
|
|
80
|
+
Napi::Env env;
|
|
81
|
+
int64_t bytes_allocated = 0;
|
|
78
82
|
};
|
|
79
83
|
|
|
80
84
|
struct JSArgs;
|
|
81
|
-
void DuckDBNodeUDFLauncher(Napi::Env env, Napi::Function jsudf, nullptr_t *, JSArgs *data);
|
|
85
|
+
void DuckDBNodeUDFLauncher(Napi::Env env, Napi::Function jsudf, std::nullptr_t *, JSArgs *data);
|
|
82
86
|
|
|
83
|
-
typedef Napi::TypedThreadSafeFunction<nullptr_t, JSArgs, DuckDBNodeUDFLauncher>
|
|
87
|
+
typedef Napi::TypedThreadSafeFunction<std::nullptr_t, JSArgs, DuckDBNodeUDFLauncher> duckdb_node_udf_function_t;
|
|
84
88
|
|
|
85
89
|
class Connection : public Napi::ObjectWrap<Connection> {
|
|
86
90
|
public:
|
|
87
|
-
Connection(const Napi::CallbackInfo &info);
|
|
88
|
-
~Connection();
|
|
91
|
+
explicit Connection(const Napi::CallbackInfo &info);
|
|
92
|
+
~Connection() override;
|
|
89
93
|
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
90
94
|
|
|
91
95
|
public:
|
|
@@ -97,8 +101,9 @@ public:
|
|
|
97
101
|
static bool HasInstance(Napi::Value val) {
|
|
98
102
|
Napi::Env env = val.Env();
|
|
99
103
|
Napi::HandleScope scope(env);
|
|
100
|
-
if (!val.IsObject())
|
|
104
|
+
if (!val.IsObject()) {
|
|
101
105
|
return false;
|
|
106
|
+
}
|
|
102
107
|
Napi::Object obj = val.As<Napi::Object>();
|
|
103
108
|
return obj.InstanceOf(constructor.Value());
|
|
104
109
|
}
|
|
@@ -107,15 +112,15 @@ public:
|
|
|
107
112
|
static Napi::FunctionReference constructor;
|
|
108
113
|
std::unique_ptr<duckdb::Connection> connection;
|
|
109
114
|
Database *database_ref;
|
|
110
|
-
std::unordered_map<std::string,
|
|
115
|
+
std::unordered_map<std::string, duckdb_node_udf_function_t> udfs;
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
struct StatementParam;
|
|
114
119
|
|
|
115
120
|
class Statement : public Napi::ObjectWrap<Statement> {
|
|
116
121
|
public:
|
|
117
|
-
Statement(const Napi::CallbackInfo &info);
|
|
118
|
-
~Statement();
|
|
122
|
+
explicit Statement(const Napi::CallbackInfo &info);
|
|
123
|
+
~Statement() override;
|
|
119
124
|
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
|
120
125
|
void SetProcessFirstParam() {
|
|
121
126
|
ignore_first_param = false;
|
|
@@ -126,8 +131,7 @@ public:
|
|
|
126
131
|
Napi::Value Each(const Napi::CallbackInfo &info);
|
|
127
132
|
Napi::Value Run(const Napi::CallbackInfo &info);
|
|
128
133
|
Napi::Value Bind(const Napi::CallbackInfo &info);
|
|
129
|
-
|
|
130
|
-
Napi::Value Finalize_(const Napi::CallbackInfo &info);
|
|
134
|
+
Napi::Value Finish(const Napi::CallbackInfo &info);
|
|
131
135
|
|
|
132
136
|
public:
|
|
133
137
|
static Napi::FunctionReference constructor;
|
|
@@ -158,4 +162,6 @@ public:
|
|
|
158
162
|
}
|
|
159
163
|
};
|
|
160
164
|
|
|
165
|
+
Napi::Array EncodeDataChunk(Napi::Env env, duckdb::DataChunk &chunk, bool with_types, bool with_data);
|
|
166
|
+
|
|
161
167
|
} // namespace node_duckdb
|