@nxtedition/rocksdb 7.0.8 → 7.0.11
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 +32 -2
- package/index.js +4 -0
- package/iterator.js +4 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
package/binding.cc
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#include <rocksdb/slice_transform.h>
|
|
15
15
|
#include <rocksdb/table.h>
|
|
16
16
|
#include <rocksdb/write_batch.h>
|
|
17
|
+
#include <rocksdb/filter_policy.h>
|
|
17
18
|
|
|
18
19
|
#include <array>
|
|
19
20
|
#include <memory>
|
|
@@ -197,6 +198,8 @@ static napi_value ToError(napi_env env, const rocksdb::Status& status) {
|
|
|
197
198
|
return CreateError(env, "LEVEL_NOT_FOUND", msg);
|
|
198
199
|
} else if (status.IsCorruption()) {
|
|
199
200
|
return CreateError(env, "LEVEL_CORRUPTION", msg);
|
|
201
|
+
} else if (status.IsTryAgain()) {
|
|
202
|
+
return CreateError(env, "LEVEL_TRYAGAIN", msg);
|
|
200
203
|
} else if (status.IsIOError()) {
|
|
201
204
|
if (msg.find("IO error: lock ") != std::string::npos) { // env_posix.cc
|
|
202
205
|
return CreateError(env, "LEVEL_LOCKED", msg);
|
|
@@ -772,6 +775,13 @@ rocksdb::Status InitOptions(napi_env env, T& columnOptions, const U& options) {
|
|
|
772
775
|
tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10));
|
|
773
776
|
}
|
|
774
777
|
|
|
778
|
+
const auto filterPolicyOpt = StringProperty(env, options, "filterPolicy");
|
|
779
|
+
if (filterPolicyOpt) {
|
|
780
|
+
rocksdb::ConfigOptions configOptions;
|
|
781
|
+
ROCKS_STATUS_RETURN(
|
|
782
|
+
rocksdb::FilterPolicy::CreateFromString(configOptions, *filterPolicyOpt, &tableOptions.filter_policy));
|
|
783
|
+
}
|
|
784
|
+
|
|
775
785
|
tableOptions.block_size = Uint32Property(env, options, "blockSize").value_or(4096);
|
|
776
786
|
tableOptions.block_restart_interval = Uint32Property(env, options, "blockRestartInterval").value_or(16);
|
|
777
787
|
tableOptions.format_version = 5;
|
|
@@ -1155,7 +1165,11 @@ struct GetManyWorker final : public Worker {
|
|
|
1155
1165
|
database_->IncrementPriorityWork(env);
|
|
1156
1166
|
}
|
|
1157
1167
|
|
|
1158
|
-
~GetManyWorker() {
|
|
1168
|
+
~GetManyWorker() {
|
|
1169
|
+
if (snapshot_) {
|
|
1170
|
+
database_->db_->ReleaseSnapshot(snapshot_);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1159
1173
|
|
|
1160
1174
|
rocksdb::Status Execute(Database& database) override {
|
|
1161
1175
|
rocksdb::ReadOptions readOptions;
|
|
@@ -1381,6 +1395,21 @@ NAPI_METHOD(db_get_property) {
|
|
|
1381
1395
|
return result;
|
|
1382
1396
|
}
|
|
1383
1397
|
|
|
1398
|
+
|
|
1399
|
+
NAPI_METHOD(db_get_latest_sequence) {
|
|
1400
|
+
NAPI_ARGV(1);
|
|
1401
|
+
|
|
1402
|
+
Database* database;
|
|
1403
|
+
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&database)));
|
|
1404
|
+
|
|
1405
|
+
const auto seq = database->db_->GetLatestSequenceNumber();
|
|
1406
|
+
|
|
1407
|
+
napi_value result;
|
|
1408
|
+
NAPI_STATUS_THROWS(napi_create_bigint_int64(env, seq, &result));
|
|
1409
|
+
|
|
1410
|
+
return result;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1384
1413
|
NAPI_METHOD(iterator_init) {
|
|
1385
1414
|
NAPI_ARGV(2);
|
|
1386
1415
|
|
|
@@ -1459,7 +1488,7 @@ NAPI_METHOD(iterator_get_sequence) {
|
|
|
1459
1488
|
napi_value result;
|
|
1460
1489
|
NAPI_STATUS_THROWS(napi_create_bigint_int64(env, seq, &result));
|
|
1461
1490
|
|
|
1462
|
-
return
|
|
1491
|
+
return result;
|
|
1463
1492
|
}
|
|
1464
1493
|
|
|
1465
1494
|
struct NextWorker final : public Worker {
|
|
@@ -1702,6 +1731,7 @@ NAPI_INIT() {
|
|
|
1702
1731
|
NAPI_EXPORT_FUNCTION(db_del);
|
|
1703
1732
|
NAPI_EXPORT_FUNCTION(db_clear);
|
|
1704
1733
|
NAPI_EXPORT_FUNCTION(db_get_property);
|
|
1734
|
+
NAPI_EXPORT_FUNCTION(db_get_latest_sequence);
|
|
1705
1735
|
|
|
1706
1736
|
NAPI_EXPORT_FUNCTION(iterator_init);
|
|
1707
1737
|
NAPI_EXPORT_FUNCTION(iterator_seek);
|
package/index.js
CHANGED
package/iterator.js
CHANGED
|
@@ -29,6 +29,10 @@ class Iterator extends AbstractIterator {
|
|
|
29
29
|
this[kPosition] = 0
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
get sequence () {
|
|
33
|
+
return binding.iterator_get_sequence(this[kContext])
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
_seek (target) {
|
|
33
37
|
if (target.length === 0) {
|
|
34
38
|
throw new Error('cannot seek() to an empty target')
|
package/package.json
CHANGED
|
Binary file
|