rocksdb-native 3.7.3 → 3.7.5
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 +39 -23
- package/lib/state.js +29 -35
- package/package.json +2 -1
- package/prebuilds/android-arm/rocksdb-native.bare +0 -0
- package/prebuilds/android-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/android-ia32/rocksdb-native.bare +0 -0
- package/prebuilds/android-x64/rocksdb-native.bare +0 -0
- package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
- package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
- package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
- package/prebuilds/ios-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/ios-arm64-simulator/rocksdb-native.bare +0 -0
- package/prebuilds/ios-x64-simulator/rocksdb-native.bare +0 -0
- package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
- package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
- package/prebuilds/linux-x64/rocksdb-native.node +0 -0
- package/prebuilds/win32-arm64/rocksdb-native.bare +0 -0
- package/prebuilds/win32-arm64/rocksdb-native.node +0 -0
- package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
- package/prebuilds/win32-x64/rocksdb-native.node +0 -0
package/binding.cc
CHANGED
|
@@ -94,7 +94,7 @@ struct rocksdb_native_iterator_t {
|
|
|
94
94
|
js_persistent_t<cb_on_iterator_close_t> on_close;
|
|
95
95
|
js_persistent_t<cb_on_iterator_read_t> on_read;
|
|
96
96
|
|
|
97
|
-
bool
|
|
97
|
+
bool active;
|
|
98
98
|
bool exiting;
|
|
99
99
|
|
|
100
100
|
js_deferred_teardown_t *teardown;
|
|
@@ -717,7 +717,7 @@ rocksdb_native_iterator_init(js_env_t *env) {
|
|
|
717
717
|
assert(err == 0);
|
|
718
718
|
|
|
719
719
|
req->env = env;
|
|
720
|
-
req->
|
|
720
|
+
req->active = false;
|
|
721
721
|
req->exiting = false;
|
|
722
722
|
req->handle.data = req;
|
|
723
723
|
|
|
@@ -757,6 +757,8 @@ rocksdb_native__on_iterator_close(rocksdb_iterator_t *handle, int status) {
|
|
|
757
757
|
|
|
758
758
|
rocksdb_native_iterator_t *req = (rocksdb_native_iterator_t *) handle->data;
|
|
759
759
|
|
|
760
|
+
req->active = false;
|
|
761
|
+
|
|
760
762
|
js_env_t *env = req->env;
|
|
761
763
|
|
|
762
764
|
js_deferred_teardown_t *teardown = req->teardown;
|
|
@@ -809,33 +811,38 @@ rocksdb_native__on_iterator_open(rocksdb_iterator_t *handle, int status) {
|
|
|
809
811
|
|
|
810
812
|
rocksdb_native_iterator_t *req = (rocksdb_native_iterator_t *) handle->data;
|
|
811
813
|
|
|
812
|
-
|
|
814
|
+
req->active = false;
|
|
813
815
|
|
|
814
|
-
|
|
816
|
+
if (req->exiting) {
|
|
817
|
+
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
818
|
+
assert(err == 0);
|
|
819
|
+
} else {
|
|
820
|
+
js_env_t *env = req->env;
|
|
815
821
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
822
|
+
js_handle_scope_t *scope;
|
|
823
|
+
err = js_open_handle_scope(env, &scope);
|
|
824
|
+
assert(err == 0);
|
|
819
825
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
826
|
+
js_receiver_t ctx;
|
|
827
|
+
err = js_get_reference_value(env, req->ctx, ctx);
|
|
828
|
+
assert(err == 0);
|
|
823
829
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
830
|
+
cb_on_iterator_open_t cb;
|
|
831
|
+
err = js_get_reference_value(env, req->on_open, cb);
|
|
832
|
+
assert(err == 0);
|
|
827
833
|
|
|
828
|
-
|
|
834
|
+
std::optional<js_string_t> error;
|
|
829
835
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
836
|
+
if (req->handle.error) {
|
|
837
|
+
err = js_create_string(env, req->handle.error, error.emplace());
|
|
838
|
+
assert(err == 0);
|
|
839
|
+
}
|
|
834
840
|
|
|
835
|
-
|
|
841
|
+
js_call_function_with_checkpoint(env, cb, ctx, error);
|
|
836
842
|
|
|
837
|
-
|
|
838
|
-
|
|
843
|
+
err = js_close_handle_scope(env, scope);
|
|
844
|
+
assert(err == 0);
|
|
845
|
+
}
|
|
839
846
|
}
|
|
840
847
|
|
|
841
848
|
static void
|
|
@@ -846,7 +853,7 @@ rocksdb_native__on_iterator_teardown(js_deferred_teardown_t *handle, void *data)
|
|
|
846
853
|
|
|
847
854
|
req->exiting = true;
|
|
848
855
|
|
|
849
|
-
if (req->
|
|
856
|
+
if (req->active) return;
|
|
850
857
|
|
|
851
858
|
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
852
859
|
assert(err == 0);
|
|
@@ -872,6 +879,8 @@ rocksdb_native_iterator_open(
|
|
|
872
879
|
) {
|
|
873
880
|
int err;
|
|
874
881
|
|
|
882
|
+
req->active = true;
|
|
883
|
+
|
|
875
884
|
rocksdb_range_t range;
|
|
876
885
|
|
|
877
886
|
err = js_get_typedarray_info(env, gt, range.gt.data, range.gt.len);
|
|
@@ -920,7 +929,7 @@ static void
|
|
|
920
929
|
rocksdb_native_iterator_close(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_iterator_t, 1> req) {
|
|
921
930
|
int err;
|
|
922
931
|
|
|
923
|
-
req->
|
|
932
|
+
req->active = true;
|
|
924
933
|
|
|
925
934
|
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
926
935
|
assert(err == 0);
|
|
@@ -944,6 +953,8 @@ rocksdb_native__on_iterator_read(rocksdb_iterator_t *handle, int status) {
|
|
|
944
953
|
|
|
945
954
|
rocksdb_native_iterator_t *req = (rocksdb_native_iterator_t *) handle->data;
|
|
946
955
|
|
|
956
|
+
req->active = false;
|
|
957
|
+
|
|
947
958
|
rocksdb_native_t *db = (rocksdb_native_t *) req->handle.req.db;
|
|
948
959
|
|
|
949
960
|
size_t len = req->handle.len;
|
|
@@ -958,6 +969,9 @@ rocksdb_native__on_iterator_read(rocksdb_iterator_t *handle, int status) {
|
|
|
958
969
|
rocksdb_slice_destroy(&req->values[i]);
|
|
959
970
|
}
|
|
960
971
|
}
|
|
972
|
+
|
|
973
|
+
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
974
|
+
assert(err == 0);
|
|
961
975
|
} else {
|
|
962
976
|
js_env_t *env = req->env;
|
|
963
977
|
|
|
@@ -1019,6 +1033,8 @@ rocksdb_native_iterator_read(
|
|
|
1019
1033
|
) {
|
|
1020
1034
|
int err;
|
|
1021
1035
|
|
|
1036
|
+
req->active = true;
|
|
1037
|
+
|
|
1022
1038
|
err = rocksdb_iterator_read(&req->handle, req->keys, req->values, capacity, rocksdb_native__on_iterator_read);
|
|
1023
1039
|
assert(err == 0);
|
|
1024
1040
|
}
|
package/lib/state.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const ReadyResource = require('ready-resource')
|
|
2
2
|
const RefCounter = require('refcounter')
|
|
3
3
|
const rrp = require('resolve-reject-promise')
|
|
4
|
+
const SignalPromise = require('signal-promise')
|
|
4
5
|
const { ReadBatch, WriteBatch } = require('./batch')
|
|
5
6
|
const ColumnFamily = require('./column-family')
|
|
6
7
|
const binding = require('../binding')
|
|
@@ -33,8 +34,9 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
33
34
|
this.resumed = null
|
|
34
35
|
|
|
35
36
|
this._suspended = false
|
|
36
|
-
this._suspending =
|
|
37
|
-
this.
|
|
37
|
+
this._suspending = false
|
|
38
|
+
this._updating = false
|
|
39
|
+
this._updatingSignal = new SignalPromise()
|
|
38
40
|
this._columnsFlushed = false
|
|
39
41
|
this._readBatches = []
|
|
40
42
|
this._writeBatches = []
|
|
@@ -158,6 +160,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
async _close() {
|
|
163
|
+
while (this._updating) await this._updatingSignal.wait()
|
|
161
164
|
if (this.resumed) this.resumed.resolve(false)
|
|
162
165
|
|
|
163
166
|
while (!this.io.isIdle()) await this.io.idle()
|
|
@@ -227,20 +230,30 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
227
230
|
}
|
|
228
231
|
}
|
|
229
232
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return this.
|
|
233
|
+
suspend() {
|
|
234
|
+
this._suspending = true
|
|
235
|
+
return this.update()
|
|
233
236
|
}
|
|
234
237
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (this._resuming !== null) await this._resuming
|
|
238
|
+
resume() {
|
|
239
|
+
this._suspending = false
|
|
240
|
+
return this.update()
|
|
241
|
+
}
|
|
241
242
|
|
|
242
|
-
|
|
243
|
+
async update() {
|
|
244
|
+
while (this._updating) await this._updatingSignal.wait()
|
|
245
|
+
if (this._suspending === this._suspended || this.closing) return
|
|
246
|
+
this._updating = true
|
|
247
|
+
try {
|
|
248
|
+
if (this._suspending) await this._suspend()
|
|
249
|
+
else await this._resume()
|
|
250
|
+
} finally {
|
|
251
|
+
this._updating = false
|
|
252
|
+
this._updatingSignal.notify()
|
|
253
|
+
}
|
|
254
|
+
}
|
|
243
255
|
|
|
256
|
+
async _suspend() {
|
|
244
257
|
if (this._suspended === true) return
|
|
245
258
|
|
|
246
259
|
while (!this.io.isIdle()) await this.io.idle()
|
|
@@ -263,8 +276,6 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
263
276
|
this._suspended = true
|
|
264
277
|
} finally {
|
|
265
278
|
this.io.dec()
|
|
266
|
-
|
|
267
|
-
this._suspending = null
|
|
268
279
|
}
|
|
269
280
|
|
|
270
281
|
function onsuspend(err) {
|
|
@@ -273,19 +284,8 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
273
284
|
}
|
|
274
285
|
}
|
|
275
286
|
|
|
276
|
-
resume() {
|
|
277
|
-
if (this._resuming === null) this._resuming = this._resume()
|
|
278
|
-
return this._resuming
|
|
279
|
-
}
|
|
280
|
-
|
|
281
287
|
async _resume() {
|
|
282
|
-
if (this.
|
|
283
|
-
|
|
284
|
-
this.io.inc()
|
|
285
|
-
|
|
286
|
-
if (this._suspending !== null) await this._suspending
|
|
287
|
-
|
|
288
|
-
if (this._suspended === false) return this.io.dec()
|
|
288
|
+
if (this._suspended === false) return
|
|
289
289
|
|
|
290
290
|
const req = { resolve: null, reject: null, handle: null }
|
|
291
291
|
|
|
@@ -294,17 +294,11 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
294
294
|
req.reject = reject
|
|
295
295
|
})
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
req.handle = binding.resume(this._handle, req, onresume)
|
|
299
|
-
|
|
300
|
-
await promise
|
|
297
|
+
req.handle = binding.resume(this._handle, req, onresume)
|
|
301
298
|
|
|
302
|
-
|
|
303
|
-
} finally {
|
|
304
|
-
this.io.dec()
|
|
299
|
+
await promise
|
|
305
300
|
|
|
306
|
-
|
|
307
|
-
}
|
|
301
|
+
this._suspended = false
|
|
308
302
|
|
|
309
303
|
const resumed = this.resumed
|
|
310
304
|
this.resumed = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rocksdb-native",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.5",
|
|
4
4
|
"description": "librocksdb bindings for JavaScript",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"refcounter": "^1.0.0",
|
|
42
42
|
"require-addon": "^1.0.2",
|
|
43
43
|
"resolve-reject-promise": "^1.1.0",
|
|
44
|
+
"signal-promise": "^1.0.3",
|
|
44
45
|
"streamx": "^2.16.1"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|