@nxtedition/rocksdb 5.2.36 → 5.2.39
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 +66 -91
- 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 +4 -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/prebuilds/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) {
|
|
@@ -96,7 +82,7 @@ static bool HasProperty(napi_env env, napi_value obj, const std::string_view& ke
|
|
|
96
82
|
}
|
|
97
83
|
|
|
98
84
|
static napi_value GetProperty(napi_env env, napi_value obj, const std::string_view& key) {
|
|
99
|
-
napi_value value;
|
|
85
|
+
napi_value value = nullptr;
|
|
100
86
|
napi_get_named_property(env, obj, key.data(), &value);
|
|
101
87
|
return value;
|
|
102
88
|
}
|
|
@@ -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
|
-
std::array<char,
|
|
224
|
+
std::array<char, 128> 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,11 @@ 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
|
+
options.max_background_jobs = std::thread::hardware_concurrency() / 4;
|
|
606
|
+
|
|
607
|
+
// TODO: Consider direct IO (https://github.com/facebook/rocksdb/wiki/Direct-IO) once
|
|
608
|
+
// secondary compressed cache is stable.
|
|
616
609
|
|
|
617
610
|
const auto infoLogLevel = StringProperty(env, argv[2], "infoLogLevel").value_or("");
|
|
618
611
|
if (infoLogLevel.size() > 0) {
|
|
@@ -648,22 +641,23 @@ NAPI_METHOD(db_open) {
|
|
|
648
641
|
|
|
649
642
|
if (cacheSize) {
|
|
650
643
|
tableOptions.block_cache = rocksdb::NewLRUCache(cacheSize);
|
|
644
|
+
tableOptions.cache_index_and_filter_blocks = BooleanProperty(env, argv[2], "cacheIndexAndFilterBlocks").value_or(true);
|
|
651
645
|
} else {
|
|
652
646
|
tableOptions.no_block_cache = true;
|
|
647
|
+
tableOptions.cache_index_and_filter_blocks = false;
|
|
653
648
|
}
|
|
654
649
|
|
|
655
650
|
tableOptions.block_size = Uint32Property(env, argv[2], "blockSize").value_or(4096);
|
|
656
651
|
tableOptions.block_restart_interval = Uint32Property(env, argv[2], "blockRestartInterval").value_or(16);
|
|
657
|
-
tableOptions.filter_policy.reset(rocksdb::
|
|
652
|
+
tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10));
|
|
658
653
|
tableOptions.format_version = 5;
|
|
659
|
-
tableOptions.checksum = rocksdb::
|
|
654
|
+
tableOptions.checksum = rocksdb::kXXH3;
|
|
655
|
+
tableOptions.optimize_filters_for_memory = BooleanProperty(env, argv[2], "optimizeFiltersForMemory").value_or(true);
|
|
660
656
|
|
|
661
657
|
options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
|
|
662
658
|
|
|
663
659
|
const auto callback = argv[3];
|
|
664
660
|
|
|
665
|
-
NAPI_PENDING_EXCEPTION();
|
|
666
|
-
|
|
667
661
|
auto worker = new OpenWorker(env, database, callback, location, options, readOnly);
|
|
668
662
|
worker->Queue(env);
|
|
669
663
|
|
|
@@ -702,10 +696,11 @@ NAPI_METHOD(db_put) {
|
|
|
702
696
|
NAPI_ARGV(4);
|
|
703
697
|
NAPI_DB_CONTEXT();
|
|
704
698
|
|
|
705
|
-
|
|
706
|
-
|
|
699
|
+
NapiSlice key;
|
|
700
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
707
701
|
|
|
708
|
-
|
|
702
|
+
NapiSlice val;
|
|
703
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[2], val));
|
|
709
704
|
|
|
710
705
|
rocksdb::WriteOptions options;
|
|
711
706
|
return ToError(env, database->db_->Put(options, key, val));
|
|
@@ -770,8 +765,6 @@ NAPI_METHOD(db_get) {
|
|
|
770
765
|
const auto fillCache = BooleanProperty(env, options, "fillCache").value_or(true);
|
|
771
766
|
const auto callback = argv[3];
|
|
772
767
|
|
|
773
|
-
NAPI_PENDING_EXCEPTION();
|
|
774
|
-
|
|
775
768
|
auto worker = new GetWorker(env, database, callback, key, asBuffer, fillCache);
|
|
776
769
|
worker->Queue(env);
|
|
777
770
|
|
|
@@ -781,12 +774,12 @@ NAPI_METHOD(db_get) {
|
|
|
781
774
|
struct GetManyWorker final : public Worker {
|
|
782
775
|
GetManyWorker(napi_env env,
|
|
783
776
|
Database* database,
|
|
784
|
-
|
|
777
|
+
std::vector<std::string> keys,
|
|
785
778
|
napi_value callback,
|
|
786
779
|
const bool valueAsBuffer,
|
|
787
780
|
const bool fillCache)
|
|
788
781
|
: Worker(env, database, callback, "leveldown.get.many"),
|
|
789
|
-
keys_(keys),
|
|
782
|
+
keys_(std::move(keys)),
|
|
790
783
|
valueAsBuffer_(valueAsBuffer),
|
|
791
784
|
fillCache_(fillCache),
|
|
792
785
|
snapshot_(database_->db_->GetSnapshot(),
|
|
@@ -888,9 +881,7 @@ NAPI_METHOD(db_get_many) {
|
|
|
888
881
|
const bool fillCache = BooleanProperty(env, options, "fillCache").value_or(true);
|
|
889
882
|
const auto callback = argv[3];
|
|
890
883
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
auto worker = new GetManyWorker(env, database, keys, callback, asBuffer, fillCache);
|
|
884
|
+
auto worker = new GetManyWorker(env, database, std::move(keys), callback, asBuffer, fillCache);
|
|
894
885
|
worker->Queue(env);
|
|
895
886
|
|
|
896
887
|
return 0;
|
|
@@ -900,9 +891,8 @@ NAPI_METHOD(db_del) {
|
|
|
900
891
|
NAPI_ARGV(3);
|
|
901
892
|
NAPI_DB_CONTEXT();
|
|
902
893
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
NAPI_PENDING_EXCEPTION();
|
|
894
|
+
NapiSlice key;
|
|
895
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
906
896
|
|
|
907
897
|
rocksdb::WriteOptions options;
|
|
908
898
|
return ToError(env, database->db_->Delete(options, key));
|
|
@@ -965,9 +955,8 @@ NAPI_METHOD(db_get_property) {
|
|
|
965
955
|
NAPI_ARGV(2);
|
|
966
956
|
NAPI_DB_CONTEXT();
|
|
967
957
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
NAPI_PENDING_EXCEPTION();
|
|
958
|
+
NapiSlice property;
|
|
959
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], property));
|
|
971
960
|
|
|
972
961
|
std::string value;
|
|
973
962
|
database->db_->GetProperty(property, &value);
|
|
@@ -1014,9 +1003,8 @@ NAPI_METHOD(iterator_seek) {
|
|
|
1014
1003
|
NAPI_ARGV(2);
|
|
1015
1004
|
NAPI_ITERATOR_CONTEXT();
|
|
1016
1005
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
NAPI_PENDING_EXCEPTION();
|
|
1006
|
+
NapiSlice target;
|
|
1007
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], target));
|
|
1020
1008
|
|
|
1021
1009
|
iterator->first_ = true;
|
|
1022
1010
|
iterator->Seek(target);
|
|
@@ -1144,31 +1132,18 @@ NAPI_METHOD(batch_do) {
|
|
|
1144
1132
|
napi_value element;
|
|
1145
1133
|
NAPI_STATUS_THROWS(napi_get_element(env, operations, i, &element));
|
|
1146
1134
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
const auto type = StringProperty(env, element, "type");
|
|
1135
|
+
NapiSlice type;
|
|
1136
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "type"), type));
|
|
1151
1137
|
|
|
1152
1138
|
if (type == "del") {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
const auto key = NapiSlice(env, GetProperty(env, element, "key"));
|
|
1157
|
-
|
|
1158
|
-
NAPI_PENDING_EXCEPTION();
|
|
1159
|
-
|
|
1139
|
+
NapiSlice key;
|
|
1140
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "key"), key));
|
|
1160
1141
|
batch.Delete(key);
|
|
1161
1142
|
} else if (type == "put") {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
const auto key = NapiSlice(env, GetProperty(env, element, "key"));
|
|
1168
|
-
const auto value = NapiSlice(env, GetProperty(env, element, "value"));
|
|
1169
|
-
|
|
1170
|
-
NAPI_PENDING_EXCEPTION();
|
|
1171
|
-
|
|
1143
|
+
NapiSlice key;
|
|
1144
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "key"), key));
|
|
1145
|
+
NapiSlice value;
|
|
1146
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, GetProperty(env, element, "value"), value));
|
|
1172
1147
|
batch.Put(key, value);
|
|
1173
1148
|
}
|
|
1174
1149
|
}
|
|
@@ -1192,10 +1167,11 @@ NAPI_METHOD(batch_put) {
|
|
|
1192
1167
|
NAPI_ARGV(3);
|
|
1193
1168
|
NAPI_BATCH_CONTEXT();
|
|
1194
1169
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1170
|
+
NapiSlice key;
|
|
1171
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
1197
1172
|
|
|
1198
|
-
|
|
1173
|
+
NapiSlice val;
|
|
1174
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[2], val));
|
|
1199
1175
|
|
|
1200
1176
|
batch->Put(key, val);
|
|
1201
1177
|
|
|
@@ -1206,9 +1182,8 @@ NAPI_METHOD(batch_del) {
|
|
|
1206
1182
|
NAPI_ARGV(2);
|
|
1207
1183
|
NAPI_BATCH_CONTEXT();
|
|
1208
1184
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
NAPI_PENDING_EXCEPTION();
|
|
1185
|
+
NapiSlice key;
|
|
1186
|
+
NAPI_STATUS_THROWS(ToNapiSlice(env, argv[1], key));
|
|
1212
1187
|
|
|
1213
1188
|
batch->Delete(key);
|
|
1214
1189
|
|