Skip to content

Commit

Permalink
Merge pull request #3 from Mause/external-buffers
Browse files Browse the repository at this point in the history
fix: don't use external buffers on platforms without support
  • Loading branch information
hannes authored Oct 6, 2023
2 parents 9bb8060 + 300279c commit 249288e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: build

./node_modules:
npm install --build-from-source
npm install --ignore-scripts

build: ./node_modules
./node_modules/.bin/node-pre-gyp build -j max --loglevel=silent
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"gypfile": true,
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.0",
"node-addon-api": "*",
"node-addon-api": "^7.0.0",
"node-gyp": "^9.3.0"
},
"binary": {
Expand Down
8 changes: 4 additions & 4 deletions src/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ struct RunPreparedTask : public Task {
// query results, the string data is owned by the QueryResult
auto result_ref_ptr = new std::shared_ptr<duckdb::QueryResult>(result_ptr);

auto array_buffer =
Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, result_ref_ptr);
auto array_buffer = Napi::Buffer<char>::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(),
deleter, result_ref_ptr);

auto typed_array = Napi::Uint8Array::New(env, blob.GetSize(), array_buffer, 0);
auto typed_array = Napi::TypedArrayOf<char>(env, array_buffer);

// TODO we should handle this in duckdb probably
if (is_header) {
Expand Down Expand Up @@ -708,7 +708,7 @@ struct GetNextArrowIpcTask : public Task {
delete static_cast<unique_ptr<duckdb::DataChunk> *>(hint);
};
auto array_buffer =
Napi::ArrayBuffer::New(env, (void *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr);
Napi::Buffer<char>::NewOrCopy(env, (char *)blob.GetData(), blob.GetSize(), deleter, data_chunk_ptr);

deferred.Resolve(array_buffer);
}
Expand Down

0 comments on commit 249288e

Please sign in to comment.