@nxtedition/rocksdb 5.2.37 → 5.2.38
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/binding.cc +62 -81
- package/deps/liburing/liburing/COPYING +502 -0
- package/deps/liburing/liburing/COPYING.GPL +339 -0
- package/deps/liburing/liburing/LICENSE +7 -0
- package/deps/liburing/liburing/Makefile +84 -0
- package/deps/liburing/liburing/Makefile.quiet +11 -0
- package/deps/liburing/liburing/README +46 -0
- package/deps/liburing/liburing/configure +420 -0
- package/deps/liburing/liburing/debian/README.Debian +7 -0
- package/deps/liburing/liburing/debian/changelog +27 -0
- package/deps/liburing/liburing/debian/compat +1 -0
- package/deps/liburing/liburing/debian/control +48 -0
- package/deps/liburing/liburing/debian/copyright +49 -0
- package/deps/liburing/liburing/debian/liburing-dev.install +4 -0
- package/deps/liburing/liburing/debian/liburing-dev.manpages +6 -0
- package/deps/liburing/liburing/debian/liburing1-udeb.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.install +1 -0
- package/deps/liburing/liburing/debian/liburing1.symbols +32 -0
- package/deps/liburing/liburing/debian/patches/series +1 -0
- package/deps/liburing/liburing/debian/rules +81 -0
- package/deps/liburing/liburing/debian/source/format +1 -0
- package/deps/liburing/liburing/debian/source/local-options +2 -0
- package/deps/liburing/liburing/debian/source/options +1 -0
- package/deps/liburing/liburing/debian/watch +3 -0
- package/deps/liburing/liburing/examples/Makefile +29 -0
- package/deps/liburing/liburing/examples/io_uring-cp.c +279 -0
- package/deps/liburing/liburing/examples/io_uring-test.c +112 -0
- package/deps/liburing/liburing/examples/link-cp.c +193 -0
- package/deps/liburing/liburing/examples/ucontext-cp.c +273 -0
- package/deps/liburing/liburing/liburing.pc.in +12 -0
- package/deps/liburing/liburing/liburing.spec +66 -0
- package/deps/liburing/liburing/make-debs.sh +53 -0
- package/deps/liburing/liburing/man/io_uring.7 +736 -0
- package/deps/liburing/liburing/man/io_uring_enter.2 +1403 -0
- package/deps/liburing/liburing/man/io_uring_get_sqe.3 +37 -0
- package/deps/liburing/liburing/man/io_uring_queue_exit.3 +27 -0
- package/deps/liburing/liburing/man/io_uring_queue_init.3 +44 -0
- package/deps/liburing/liburing/man/io_uring_register.2 +605 -0
- package/deps/liburing/liburing/man/io_uring_setup.2 +515 -0
- package/deps/liburing/liburing/src/Makefile +76 -0
- package/deps/liburing/liburing/src/include/liburing/barrier.h +73 -0
- package/deps/liburing/liburing/src/include/liburing/io_uring.h +422 -0
- package/deps/liburing/liburing/src/include/liburing.h +775 -0
- package/deps/liburing/liburing/src/liburing.map +46 -0
- package/deps/liburing/liburing/src/queue.c +403 -0
- package/deps/liburing/liburing/src/register.c +299 -0
- package/deps/liburing/liburing/src/setup.c +356 -0
- package/deps/liburing/liburing/src/syscall.c +73 -0
- package/deps/liburing/liburing/src/syscall.h +20 -0
- package/deps/liburing/liburing/test/232c93d07b74-test.c +305 -0
- package/deps/liburing/liburing/test/35fa71a030ca-test.c +329 -0
- package/deps/liburing/liburing/test/500f9fbadef8-test.c +89 -0
- package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +93 -0
- package/deps/liburing/liburing/test/8a9973408177-test.c +106 -0
- package/deps/liburing/liburing/test/917257daa0fe-test.c +53 -0
- package/deps/liburing/liburing/test/Makefile +312 -0
- package/deps/liburing/liburing/test/a0908ae19763-test.c +58 -0
- package/deps/liburing/liburing/test/a4c0b3decb33-test.c +180 -0
- package/deps/liburing/liburing/test/accept-link.c +251 -0
- package/deps/liburing/liburing/test/accept-reuse.c +164 -0
- package/deps/liburing/liburing/test/accept-test.c +79 -0
- package/deps/liburing/liburing/test/accept.c +476 -0
- package/deps/liburing/liburing/test/across-fork.c +283 -0
- package/deps/liburing/liburing/test/b19062a56726-test.c +53 -0
- package/deps/liburing/liburing/test/b5837bd5311d-test.c +77 -0
- package/deps/liburing/liburing/test/ce593a6c480a-test.c +135 -0
- package/deps/liburing/liburing/test/close-opath.c +122 -0
- package/deps/liburing/liburing/test/config +10 -0
- package/deps/liburing/liburing/test/connect.c +398 -0
- package/deps/liburing/liburing/test/cq-full.c +96 -0
- package/deps/liburing/liburing/test/cq-overflow.c +294 -0
- package/deps/liburing/liburing/test/cq-peek-batch.c +102 -0
- package/deps/liburing/liburing/test/cq-ready.c +94 -0
- package/deps/liburing/liburing/test/cq-size.c +58 -0
- package/deps/liburing/liburing/test/d4ae271dfaae-test.c +96 -0
- package/deps/liburing/liburing/test/d77a67ed5f27-test.c +65 -0
- package/deps/liburing/liburing/test/defer.c +307 -0
- package/deps/liburing/liburing/test/double-poll-crash.c +186 -0
- package/deps/liburing/liburing/test/eeed8b54e0df-test.c +114 -0
- package/deps/liburing/liburing/test/empty-eownerdead.c +42 -0
- package/deps/liburing/liburing/test/eventfd-disable.c +151 -0
- package/deps/liburing/liburing/test/eventfd-ring.c +97 -0
- package/deps/liburing/liburing/test/eventfd.c +112 -0
- package/deps/liburing/liburing/test/fadvise.c +202 -0
- package/deps/liburing/liburing/test/fallocate.c +249 -0
- package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +138 -0
- package/deps/liburing/liburing/test/file-register.c +843 -0
- package/deps/liburing/liburing/test/file-update.c +173 -0
- package/deps/liburing/liburing/test/files-exit-hang-poll.c +128 -0
- package/deps/liburing/liburing/test/files-exit-hang-timeout.c +134 -0
- package/deps/liburing/liburing/test/fixed-link.c +90 -0
- package/deps/liburing/liburing/test/fsync.c +224 -0
- package/deps/liburing/liburing/test/hardlink.c +136 -0
- package/deps/liburing/liburing/test/helpers.c +135 -0
- package/deps/liburing/liburing/test/helpers.h +67 -0
- package/deps/liburing/liburing/test/io-cancel.c +537 -0
- package/deps/liburing/liburing/test/io_uring_enter.c +296 -0
- package/deps/liburing/liburing/test/io_uring_register.c +664 -0
- package/deps/liburing/liburing/test/io_uring_setup.c +192 -0
- package/deps/liburing/liburing/test/iopoll.c +366 -0
- package/deps/liburing/liburing/test/lfs-openat-write.c +117 -0
- package/deps/liburing/liburing/test/lfs-openat.c +273 -0
- package/deps/liburing/liburing/test/link-timeout.c +1107 -0
- package/deps/liburing/liburing/test/link.c +496 -0
- package/deps/liburing/liburing/test/link_drain.c +229 -0
- package/deps/liburing/liburing/test/madvise.c +195 -0
- package/deps/liburing/liburing/test/mkdir.c +108 -0
- package/deps/liburing/liburing/test/multicqes_drain.c +383 -0
- package/deps/liburing/liburing/test/nop-all-sizes.c +107 -0
- package/deps/liburing/liburing/test/nop.c +115 -0
- package/deps/liburing/liburing/test/open-close.c +146 -0
- package/deps/liburing/liburing/test/openat2.c +240 -0
- package/deps/liburing/liburing/test/personality.c +204 -0
- package/deps/liburing/liburing/test/pipe-eof.c +81 -0
- package/deps/liburing/liburing/test/pipe-reuse.c +105 -0
- package/deps/liburing/liburing/test/poll-cancel-ton.c +139 -0
- package/deps/liburing/liburing/test/poll-cancel.c +135 -0
- package/deps/liburing/liburing/test/poll-link.c +227 -0
- package/deps/liburing/liburing/test/poll-many.c +208 -0
- package/deps/liburing/liburing/test/poll-mshot-update.c +273 -0
- package/deps/liburing/liburing/test/poll-ring.c +48 -0
- package/deps/liburing/liburing/test/poll-v-poll.c +353 -0
- package/deps/liburing/liburing/test/poll.c +109 -0
- package/deps/liburing/liburing/test/probe.c +137 -0
- package/deps/liburing/liburing/test/read-write.c +876 -0
- package/deps/liburing/liburing/test/register-restrictions.c +633 -0
- package/deps/liburing/liburing/test/rename.c +134 -0
- package/deps/liburing/liburing/test/ring-leak.c +173 -0
- package/deps/liburing/liburing/test/ring-leak2.c +249 -0
- package/deps/liburing/liburing/test/rsrc_tags.c +449 -0
- package/deps/liburing/liburing/test/runtests-loop.sh +16 -0
- package/deps/liburing/liburing/test/runtests.sh +170 -0
- package/deps/liburing/liburing/test/rw_merge_test.c +97 -0
- package/deps/liburing/liburing/test/self.c +91 -0
- package/deps/liburing/liburing/test/send_recv.c +291 -0
- package/deps/liburing/liburing/test/send_recvmsg.c +345 -0
- package/deps/liburing/liburing/test/sendmsg_fs_cve.c +198 -0
- package/deps/liburing/liburing/test/shared-wq.c +84 -0
- package/deps/liburing/liburing/test/short-read.c +75 -0
- package/deps/liburing/liburing/test/shutdown.c +163 -0
- package/deps/liburing/liburing/test/sigfd-deadlock.c +74 -0
- package/deps/liburing/liburing/test/socket-rw-eagain.c +156 -0
- package/deps/liburing/liburing/test/socket-rw.c +147 -0
- package/deps/liburing/liburing/test/splice.c +511 -0
- package/deps/liburing/liburing/test/sq-full-cpp.cc +45 -0
- package/deps/liburing/liburing/test/sq-full.c +45 -0
- package/deps/liburing/liburing/test/sq-poll-dup.c +200 -0
- package/deps/liburing/liburing/test/sq-poll-kthread.c +168 -0
- package/deps/liburing/liburing/test/sq-poll-share.c +137 -0
- package/deps/liburing/liburing/test/sq-space_left.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +159 -0
- package/deps/liburing/liburing/test/sqpoll-disable-exit.c +195 -0
- package/deps/liburing/liburing/test/sqpoll-exit-hang.c +77 -0
- package/deps/liburing/liburing/test/sqpoll-sleep.c +68 -0
- package/deps/liburing/liburing/test/statx.c +172 -0
- package/deps/liburing/liburing/test/stdout.c +232 -0
- package/deps/liburing/liburing/test/submit-link-fail.c +154 -0
- package/deps/liburing/liburing/test/submit-reuse.c +239 -0
- package/deps/liburing/liburing/test/symlink.c +116 -0
- package/deps/liburing/liburing/test/teardowns.c +58 -0
- package/deps/liburing/liburing/test/thread-exit.c +131 -0
- package/deps/liburing/liburing/test/timeout-new.c +246 -0
- package/deps/liburing/liburing/test/timeout-overflow.c +204 -0
- package/deps/liburing/liburing/test/timeout.c +1354 -0
- package/deps/liburing/liburing/test/unlink.c +111 -0
- package/deps/liburing/liburing/test/wakeup-hang.c +162 -0
- package/deps/liburing/liburing.gyp +20 -0
- package/deps/rocksdb/rocksdb/db/corruption_test.cc +62 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +7 -62
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +25 -11
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +74 -155
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +1 -2
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +2 -2
- package/deps/rocksdb/rocksdb/env/fs_posix.cc +13 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +4 -2
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +22 -4
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +15 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +5 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/monitoring/statistics.cc +3 -0
- package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +3 -7
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -29
- package/deps/rocksdb/rocksdb.gyp +2 -3
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
package/binding.cc
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include <set>
|
|
20
20
|
#include <string>
|
|
21
21
|
#include <vector>
|
|
22
|
+
#include <thread>
|
|
22
23
|
|
|
23
24
|
class NullLogger : public rocksdb::Logger {
|
|
24
25
|
public:
|
|
@@ -38,15 +39,6 @@ struct Iterator;
|
|
|
38
39
|
} \
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
#define NAPI_PENDING_EXCEPTION() \
|
|
42
|
-
{ \
|
|
43
|
-
bool result; \
|
|
44
|
-
NAPI_STATUS_THROWS(napi_is_exception_pending(env, &result)); \
|
|
45
|
-
if (result) { \
|
|
46
|
-
return nullptr; \
|
|
47
|
-
} \
|
|
48
|
-
}
|
|
49
|
-
|
|
50
42
|
#define NAPI_DB_CONTEXT() \
|
|
51
43
|
Database* database = nullptr; \
|
|
52
44
|
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], (void**)&database));
|
|
@@ -71,12 +63,6 @@ static bool IsBuffer(napi_env env, napi_value value) {
|
|
|
71
63
|
return isBuffer;
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
static bool IsObject(napi_env env, napi_value value) {
|
|
75
|
-
napi_valuetype type;
|
|
76
|
-
napi_typeof(env, value, &type);
|
|
77
|
-
return type == napi_object;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
66
|
static napi_value CreateError(napi_env env, const std::optional<std::string_view>& code, const std::string_view& msg) {
|
|
81
67
|
napi_value codeValue = nullptr;
|
|
82
68
|
if (code) {
|
|
@@ -226,38 +212,39 @@ napi_status Convert(napi_env env, std::string s, bool asBuffer, napi_value& resu
|
|
|
226
212
|
napi_status Convert(napi_env env, rocksdb::PinnableSlice s, bool asBuffer, napi_value& result) {
|
|
227
213
|
if (asBuffer) {
|
|
228
214
|
auto ptr = new rocksdb::PinnableSlice(std::move(s));
|
|
229
|
-
return napi_create_external_buffer(env, ptr->size(), const_cast<char*>(ptr->data()),
|
|
230
|
-
&result);
|
|
215
|
+
return napi_create_external_buffer(env, ptr->size(), const_cast<char*>(ptr->data()),
|
|
216
|
+
Finalize<rocksdb::PinnableSlice>, ptr, &result);
|
|
231
217
|
} else {
|
|
232
218
|
return napi_create_string_utf8(env, s.data(), s.size(), &result);
|
|
233
219
|
}
|
|
234
220
|
}
|
|
235
221
|
|
|
236
222
|
struct NapiSlice : public rocksdb::Slice {
|
|
237
|
-
NapiSlice(napi_env env, napi_value from) {
|
|
238
|
-
if (IsString(env, from)) {
|
|
239
|
-
NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, nullptr, 0, &size_));
|
|
240
|
-
char* data;
|
|
241
|
-
if (size_ + 1 < stack_.size()) {
|
|
242
|
-
data = stack_.data();
|
|
243
|
-
} else {
|
|
244
|
-
heap_.reset(new char[size_ + 1]);
|
|
245
|
-
data = heap_.get();
|
|
246
|
-
}
|
|
247
|
-
data[size_] = 0;
|
|
248
|
-
NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, data, size_ + 1, &size_));
|
|
249
|
-
data_ = data;
|
|
250
|
-
} else if (IsBuffer(env, from)) {
|
|
251
|
-
void* data;
|
|
252
|
-
NAPI_STATUS_THROWS_VOID(napi_get_buffer_info(env, from, &data, &size_));
|
|
253
|
-
data_ = static_cast<char*>(data);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
223
|
std::unique_ptr<char[]> heap_;
|
|
258
224
|
std::array<char, 1024> stack_;
|
|
259
225
|
};
|
|
260
226
|
|
|
227
|
+
napi_status ToNapiSlice(napi_env env, napi_value from, NapiSlice& slice) {
|
|
228
|
+
if (IsString(env, from)) {
|
|
229
|
+
NAPI_STATUS_RETURN(napi_get_value_string_utf8(env, from, nullptr, 0, &slice.size_));
|
|
230
|
+
char* data;
|
|
231
|
+
if (slice.size_ + 1 < slice.stack_.size()) {
|
|
232
|
+
data = slice.stack_.data();
|
|
233
|
+
} else {
|
|
234
|
+
slice.heap_.reset(new char[slice.size_ + 1]);
|
|
235
|
+
data = slice.heap_.get();
|
|
236
|
+
}
|
|
237
|
+
data[slice.size_] = 0;
|
|
238
|
+
NAPI_STATUS_RETURN(napi_get_value_string_utf8(env, from, data, slice.size_ + 1, &slice.size_));
|
|
239
|
+
slice.data_ = data;
|
|
240
|
+
} else if (IsBuffer(env, from)) {
|
|
241
|
+
void* data;
|
|
242
|
+
NAPI_STATUS_RETURN(napi_get_buffer_info(env, from, &data, &slice.size_));
|
|
243
|
+
slice.data_ = static_cast<char*>(data);
|
|
244
|
+
}
|
|
245
|
+
return napi_ok;
|
|
246
|
+
}
|
|
247
|
+
|
|
261
248
|
/**
|
|
262
249
|
* Base worker class. Handles the async work. Derived classes can override the
|
|
263
250
|
* following virtual methods (listed in the order in which they're called):
|
|
@@ -587,7 +574,7 @@ struct OpenWorker final : public Worker {
|
|
|
587
574
|
location_(location) {}
|
|
588
575
|
|
|
589
576
|
rocksdb::Status Execute(Database& database) override {
|
|
590
|
-
rocksdb::DB* db;
|
|
577
|
+
rocksdb::DB* db = nullptr;
|
|
591
578
|
const auto status = readOnly_ ? rocksdb::DB::OpenForReadOnly(options_, location_, &db)
|
|
592
579
|
: rocksdb::DB::Open(options_, location_, &db);
|
|
593
580
|
database.db_.reset(db);
|
|
@@ -605,7 +592,8 @@ NAPI_METHOD(db_open) {
|
|
|
605
592
|
|
|
606
593
|
rocksdb::Options options;
|
|
607
594
|
|
|
608
|
-
options.IncreaseParallelism(
|
|
595
|
+
options.IncreaseParallelism(
|
|
596
|
+
Uint32Property(env, argv[2], "parallelism").value_or(std::thread::hardware_concurrency() / 2));
|
|
609
597
|
|
|
610
598
|
const auto location = ToString(env, argv[1]);
|
|
611
599
|
options.create_if_missing = BooleanProperty(env, argv[2], "createIfMissing").value_or(true);
|
|
@@ -613,6 +601,10 @@ NAPI_METHOD(db_open) {
|
|
|
613
601
|
options.compression = BooleanProperty(env, argv[2], "compression").value_or((true)) ? rocksdb::kSnappyCompression
|
|
614
602
|
: rocksdb::kNoCompression;
|
|
615
603
|
options.use_adaptive_mutex = true;
|
|
604
|
+
options.enable_pipelined_write = true;
|
|
605
|
+
|
|
606
|
+
// TODO: Consider direct IO (https://github.com/facebook/rocksdb/wiki/Direct-IO) once
|
|
607
|
+
// secondary compressed cache is stable.
|
|
616
608
|
|
|
617
609
|
const auto infoLogLevel = StringProperty(env, argv[2], "infoLogLevel").value_or("");
|
|
618
610
|
if (infoLogLevel.size() > 0) {
|
|
@@ -654,16 +646,16 @@ NAPI_METHOD(db_open) {
|
|
|
654
646
|
|
|
655
647
|
tableOptions.block_size = Uint32Property(env, argv[2], "blockSize").value_or(4096);
|
|
656
648
|
tableOptions.block_restart_interval = Uint32Property(env, argv[2], "blockRestartInterval").value_or(16);
|
|
657
|
-
tableOptions.filter_policy.reset(rocksdb::
|
|
649
|
+
tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10));
|
|
658
650
|
tableOptions.format_version = 5;
|
|
659
|
-
tableOptions.checksum = rocksdb::
|
|
651
|
+
tableOptions.checksum = rocksdb::kXXH3;
|
|
652
|
+
tableOptions.optimize_filters_for_memory = BooleanProperty(env, argv[2], "optimizeFiltersForMemory").value_or(true);
|
|
653
|
+
tableOptions.cache_index_and_filter_blocks = BooleanProperty(env, argv[2], "cacheIndexAndFilterBlocks").value_or(true);
|
|
660
654
|
|
|
661
655
|
options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
|
|
662
656
|
|
|
663
657
|
const auto callback = argv[3];
|
|
664
658
|
|
|
665
|
-
NAPI_PENDING_EXCEPTION();
|
|
666
|
-
|
|
667
659
|
auto worker = new OpenWorker(env, database, callback, location, options, readOnly);
|
|
668
660
|
worker->Queue(env);
|
|
669
661
|
|
|
@@ -702,10 +694,11 @@ NAPI_METHOD(db_put) {
|
|
|
702
694
|
NAPI_ARGV(4);
|
|
703
695
|
NAPI_DB_CONTEXT();
|
|
704
696
|
|
|
705
|
-
|
|
706
|
-
|
|
697
|
+
NapiSlice key;
|
|
698
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
707
699
|
|
|
708
|
-
|
|
700
|
+
NapiSlice val;
|
|
701
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[2], val));
|
|
709
702
|
|
|
710
703
|
rocksdb::WriteOptions options;
|
|
711
704
|
return ToError(env, database->db_->Put(options, key, val));
|
|
@@ -770,8 +763,6 @@ NAPI_METHOD(db_get) {
|
|
|
770
763
|
const auto fillCache = BooleanProperty(env, options, "fillCache").value_or(true);
|
|
771
764
|
const auto callback = argv[3];
|
|
772
765
|
|
|
773
|
-
NAPI_PENDING_EXCEPTION();
|
|
774
|
-
|
|
775
766
|
auto worker = new GetWorker(env, database, callback, key, asBuffer, fillCache);
|
|
776
767
|
worker->Queue(env);
|
|
777
768
|
|
|
@@ -781,12 +772,12 @@ NAPI_METHOD(db_get) {
|
|
|
781
772
|
struct GetManyWorker final : public Worker {
|
|
782
773
|
GetManyWorker(napi_env env,
|
|
783
774
|
Database* database,
|
|
784
|
-
|
|
775
|
+
std::vector<std::string> keys,
|
|
785
776
|
napi_value callback,
|
|
786
777
|
const bool valueAsBuffer,
|
|
787
778
|
const bool fillCache)
|
|
788
779
|
: Worker(env, database, callback, "leveldown.get.many"),
|
|
789
|
-
keys_(keys),
|
|
780
|
+
keys_(std::move(keys)),
|
|
790
781
|
valueAsBuffer_(valueAsBuffer),
|
|
791
782
|
fillCache_(fillCache),
|
|
792
783
|
snapshot_(database_->db_->GetSnapshot(),
|
|
@@ -888,9 +879,7 @@ NAPI_METHOD(db_get_many) {
|
|
|
888
879
|
const bool fillCache = BooleanProperty(env, options, "fillCache").value_or(true);
|
|
889
880
|
const auto callback = argv[3];
|
|
890
881
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
auto worker = new GetManyWorker(env, database, keys, callback, asBuffer, fillCache);
|
|
882
|
+
auto worker = new GetManyWorker(env, database, std::move(keys), callback, asBuffer, fillCache);
|
|
894
883
|
worker->Queue(env);
|
|
895
884
|
|
|
896
885
|
return 0;
|
|
@@ -900,9 +889,8 @@ NAPI_METHOD(db_del) {
|
|
|
900
889
|
NAPI_ARGV(3);
|
|
901
890
|
NAPI_DB_CONTEXT();
|
|
902
891
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
NAPI_PENDING_EXCEPTION();
|
|
892
|
+
NapiSlice key;
|
|
893
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
906
894
|
|
|
907
895
|
rocksdb::WriteOptions options;
|
|
908
896
|
return ToError(env, database->db_->Delete(options, key));
|
|
@@ -965,9 +953,8 @@ NAPI_METHOD(db_get_property) {
|
|
|
965
953
|
NAPI_ARGV(2);
|
|
966
954
|
NAPI_DB_CONTEXT();
|
|
967
955
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
NAPI_PENDING_EXCEPTION();
|
|
956
|
+
NapiSlice property;
|
|
957
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], property));
|
|
971
958
|
|
|
972
959
|
std::string value;
|
|
973
960
|
database->db_->GetProperty(property, &value);
|
|
@@ -1014,9 +1001,8 @@ NAPI_METHOD(iterator_seek) {
|
|
|
1014
1001
|
NAPI_ARGV(2);
|
|
1015
1002
|
NAPI_ITERATOR_CONTEXT();
|
|
1016
1003
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
NAPI_PENDING_EXCEPTION();
|
|
1004
|
+
NapiSlice target;
|
|
1005
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], target));
|
|
1020
1006
|
|
|
1021
1007
|
iterator->first_ = true;
|
|
1022
1008
|
iterator->Seek(target);
|
|
@@ -1144,23 +1130,18 @@ NAPI_METHOD(batch_do) {
|
|
|
1144
1130
|
napi_value element;
|
|
1145
1131
|
NAPI_STATUS_THROWS(napi_get_element(env, operations, i, &element));
|
|
1146
1132
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
const auto type = StringProperty(env, element, "type");
|
|
1133
|
+
NapiSlice type;
|
|
1134
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "type"), type));
|
|
1151
1135
|
|
|
1152
1136
|
if (type == "del") {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
NAPI_PENDING_EXCEPTION();
|
|
1156
|
-
|
|
1137
|
+
NapiSlice key;
|
|
1138
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "key"), key));
|
|
1157
1139
|
batch.Delete(key);
|
|
1158
1140
|
} else if (type == "put") {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1141
|
+
NapiSlice key;
|
|
1142
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "key"), key));
|
|
1143
|
+
NapiSlice value;
|
|
1144
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "value"), value));
|
|
1164
1145
|
batch.Put(key, value);
|
|
1165
1146
|
}
|
|
1166
1147
|
}
|
|
@@ -1184,10 +1165,11 @@ NAPI_METHOD(batch_put) {
|
|
|
1184
1165
|
NAPI_ARGV(3);
|
|
1185
1166
|
NAPI_BATCH_CONTEXT();
|
|
1186
1167
|
|
|
1187
|
-
|
|
1188
|
-
|
|
1168
|
+
NapiSlice key;
|
|
1169
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
1189
1170
|
|
|
1190
|
-
|
|
1171
|
+
NapiSlice val;
|
|
1172
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[2], val));
|
|
1191
1173
|
|
|
1192
1174
|
batch->Put(key, val);
|
|
1193
1175
|
|
|
@@ -1198,9 +1180,8 @@ NAPI_METHOD(batch_del) {
|
|
|
1198
1180
|
NAPI_ARGV(2);
|
|
1199
1181
|
NAPI_BATCH_CONTEXT();
|
|
1200
1182
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
NAPI_PENDING_EXCEPTION();
|
|
1183
|
+
NapiSlice key;
|
|
1184
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
1204
1185
|
|
|
1205
1186
|
batch->Delete(key);
|
|
1206
1187
|
|