@nxtedition/rocksdb 7.1.8 → 7.1.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 +19 -5
- package/index.js +7 -4
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
package/binding.cc
CHANGED
|
@@ -1495,23 +1495,37 @@ NAPI_METHOD(batch_write) {
|
|
|
1495
1495
|
napi_ref batchRef;
|
|
1496
1496
|
NAPI_STATUS_THROWS(napi_create_reference(env, argv[1], 1, &batchRef));
|
|
1497
1497
|
|
|
1498
|
-
|
|
1499
|
-
runAsync<State>(
|
|
1498
|
+
runAsync<int64_t>(
|
|
1500
1499
|
"leveldown.batch.write", env, callback,
|
|
1501
|
-
[=](
|
|
1500
|
+
[=](int64_t& seq) {
|
|
1502
1501
|
rocksdb::WriteOptions writeOptions;
|
|
1503
1502
|
writeOptions.sync = *sync;
|
|
1503
|
+
|
|
1504
|
+
// TODO (fix): Better way to get final batch sequence?
|
|
1505
|
+
seq = database->db->GetLatestSequenceNumber() + 1;
|
|
1506
|
+
|
|
1504
1507
|
return database->db->Write(writeOptions, batch);
|
|
1505
1508
|
},
|
|
1506
|
-
[=](
|
|
1509
|
+
[=](int64_t& seq, auto env, auto& argv) {
|
|
1510
|
+
argv.resize(2);
|
|
1511
|
+
NAPI_STATUS_RETURN(napi_delete_reference(env, batchRef));
|
|
1512
|
+
NAPI_STATUS_RETURN(napi_create_int64(env, seq, &argv[1]));
|
|
1513
|
+
return napi_ok;
|
|
1514
|
+
});
|
|
1507
1515
|
} else {
|
|
1516
|
+
// TODO (fix): Better way to get final batch sequence?
|
|
1517
|
+
auto seq = database->db->GetLatestSequenceNumber() + 1;
|
|
1518
|
+
|
|
1519
|
+
napi_value result;
|
|
1520
|
+
NAPI_STATUS_THROWS(napi_create_int64(env, seq, &result));
|
|
1521
|
+
|
|
1508
1522
|
rocksdb::WriteOptions writeOptions;
|
|
1509
1523
|
ROCKS_STATUS_THROWS_NAPI(database->db->Write(writeOptions, batch));
|
|
1510
1524
|
|
|
1511
1525
|
napi_value global;
|
|
1512
1526
|
NAPI_STATUS_THROWS(napi_get_global(env, &global));
|
|
1513
1527
|
|
|
1514
|
-
NAPI_STATUS_THROWS(napi_call_function(env, global, callback,
|
|
1528
|
+
NAPI_STATUS_THROWS(napi_call_function(env, global, callback, 1, &result, nullptr));
|
|
1515
1529
|
}
|
|
1516
1530
|
|
|
1517
1531
|
return 0;
|
package/index.js
CHANGED
|
@@ -115,7 +115,7 @@ class RocksLevel extends AbstractLevel {
|
|
|
115
115
|
[kUnref] () {
|
|
116
116
|
this[kRefs]--
|
|
117
117
|
if (this[kRefs] === 0 && this[kPendingClose]) {
|
|
118
|
-
this[kPendingClose]
|
|
118
|
+
process.nextTick(this[kPendingClose])
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -205,12 +205,15 @@ class RocksLevel extends AbstractLevel {
|
|
|
205
205
|
try {
|
|
206
206
|
const seq = this.sequence
|
|
207
207
|
let sync = true
|
|
208
|
-
|
|
208
|
+
this[kRef]()
|
|
209
|
+
binding.batch_write(this[kContext], context, options, (err, sequence) => {
|
|
210
|
+
this[kUnref]()
|
|
211
|
+
|
|
209
212
|
if (!err) {
|
|
210
213
|
this.emit('update', {
|
|
211
214
|
rows: batch.toArray(),
|
|
212
215
|
count: batch.length,
|
|
213
|
-
sequence: seq + 1
|
|
216
|
+
sequence: sequence ?? (seq + 1)
|
|
214
217
|
})
|
|
215
218
|
}
|
|
216
219
|
if (sync) {
|
|
@@ -343,7 +346,7 @@ class RocksLevel extends AbstractLevel {
|
|
|
343
346
|
const db = this
|
|
344
347
|
|
|
345
348
|
try {
|
|
346
|
-
let since = options.since
|
|
349
|
+
let since = (options.since ?? 0) + 1
|
|
347
350
|
while (true) {
|
|
348
351
|
const buffer = new Readable({
|
|
349
352
|
signal: ac.signal,
|
package/package.json
CHANGED
|
Binary file
|