rocksdb-native 3.11.0 → 3.11.2
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/CMakeLists.txt +1 -1
- package/binding.cc +72 -60
- package/lib/state.js +1 -5
- package/package.json +1 -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/CMakeLists.txt
CHANGED
|
@@ -9,7 +9,7 @@ project(rocksdb_native C CXX)
|
|
|
9
9
|
|
|
10
10
|
bare_target(target)
|
|
11
11
|
|
|
12
|
-
fetch_package("github:holepunchto/librocksdb#
|
|
12
|
+
fetch_package("github:holepunchto/librocksdb#6a480d5")
|
|
13
13
|
fetch_package("github:holepunchto/libjstl#098664c")
|
|
14
14
|
|
|
15
15
|
add_bare_module(rocksdb_native_bare)
|
package/binding.cc
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#include <set>
|
|
2
|
+
|
|
1
3
|
#include <assert.h>
|
|
2
4
|
#include <bare.h>
|
|
3
5
|
#include <js.h>
|
|
@@ -21,14 +23,23 @@ using rocksdb_native_on_iterator_read_t = js_function_t<void, js_receiver_t, std
|
|
|
21
23
|
using rocksdb_native_on_compact_range_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
22
24
|
using rocksdb_native_on_approximate_size_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>, uint64_t>;
|
|
23
25
|
|
|
26
|
+
struct rocksdb_native_t;
|
|
27
|
+
|
|
24
28
|
struct rocksdb_native_column_family_t {
|
|
25
29
|
rocksdb_column_family_t *handle;
|
|
26
30
|
rocksdb_column_family_descriptor_t descriptor;
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
rocksdb_native_t *db;
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
js_persistent_t<js_arraybuffer_t> ctx;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
struct rocksdb_native_snapshot_t {
|
|
38
|
+
rocksdb_snapshot_t handle;
|
|
39
|
+
|
|
40
|
+
rocksdb_native_t *db;
|
|
41
|
+
|
|
42
|
+
js_persistent_t<js_arraybuffer_t> ctx;
|
|
32
43
|
};
|
|
33
44
|
|
|
34
45
|
struct rocksdb_native_t {
|
|
@@ -41,6 +52,9 @@ struct rocksdb_native_t {
|
|
|
41
52
|
bool closing;
|
|
42
53
|
bool exiting;
|
|
43
54
|
|
|
55
|
+
std::set<rocksdb_native_column_family_t *> column_families;
|
|
56
|
+
std::set<rocksdb_native_snapshot_t *> snapshots;
|
|
57
|
+
|
|
44
58
|
js_deferred_teardown_t *teardown;
|
|
45
59
|
};
|
|
46
60
|
|
|
@@ -130,10 +144,6 @@ struct rocksdb_native_flush_t {
|
|
|
130
144
|
js_persistent_t<rocksdb_native_column_family_t> column_family;
|
|
131
145
|
};
|
|
132
146
|
|
|
133
|
-
struct rocksdb_native_snapshot_t {
|
|
134
|
-
rocksdb_snapshot_t handle;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
147
|
struct rocksdb_native_compact_range_t {
|
|
138
148
|
rocksdb_compact_range_t handle;
|
|
139
149
|
|
|
@@ -170,9 +180,6 @@ rocksdb_native__try_create_external_arraybuffer(js_env_t *env, char *data, size_
|
|
|
170
180
|
return 0;
|
|
171
181
|
}
|
|
172
182
|
|
|
173
|
-
static void
|
|
174
|
-
rocksdb_native__on_column_family_teardown(void *data);
|
|
175
|
-
|
|
176
183
|
static void
|
|
177
184
|
rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
178
185
|
int err;
|
|
@@ -238,11 +245,10 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
238
245
|
|
|
239
246
|
column_family->handle = handles[i];
|
|
240
247
|
|
|
241
|
-
err = js_create_reference(env,
|
|
248
|
+
err = js_create_reference(env, handle, column_family->ctx);
|
|
242
249
|
assert(err == 0);
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
assert(err == 0);
|
|
251
|
+
db->column_families.insert(column_family);
|
|
246
252
|
}
|
|
247
253
|
}
|
|
248
254
|
|
|
@@ -256,6 +262,32 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
256
262
|
}
|
|
257
263
|
}
|
|
258
264
|
|
|
265
|
+
static void
|
|
266
|
+
rocksdb_native__on_idle(rocksdb_t *handle) {
|
|
267
|
+
int err;
|
|
268
|
+
|
|
269
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(handle);
|
|
270
|
+
|
|
271
|
+
for (auto &column_family : db->column_families) {
|
|
272
|
+
err = rocksdb_column_family_destroy(&column_family->db->handle, column_family->handle);
|
|
273
|
+
assert(err == 0);
|
|
274
|
+
|
|
275
|
+
column_family->handle = nullptr;
|
|
276
|
+
|
|
277
|
+
column_family->ctx.reset();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
db->column_families.~set();
|
|
281
|
+
|
|
282
|
+
for (auto &snapshot : db->snapshots) {
|
|
283
|
+
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
284
|
+
|
|
285
|
+
snapshot->ctx.reset();
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
db->snapshots.~set();
|
|
289
|
+
}
|
|
290
|
+
|
|
259
291
|
static void
|
|
260
292
|
rocksdb_native__on_close(rocksdb_close_t *handle, int status) {
|
|
261
293
|
int err;
|
|
@@ -271,14 +303,14 @@ rocksdb_native__on_close(rocksdb_close_t *handle, int status) {
|
|
|
271
303
|
auto teardown = db->teardown;
|
|
272
304
|
|
|
273
305
|
if (db->exiting) {
|
|
274
|
-
db->ctx.reset();
|
|
275
|
-
|
|
276
306
|
if (db->closing) {
|
|
277
307
|
req->on_close.reset();
|
|
278
308
|
req->ctx.reset();
|
|
279
309
|
} else {
|
|
280
310
|
free(req);
|
|
281
311
|
}
|
|
312
|
+
|
|
313
|
+
db->ctx.reset();
|
|
282
314
|
} else {
|
|
283
315
|
js_handle_scope_t *scope;
|
|
284
316
|
err = js_open_handle_scope(env, &scope);
|
|
@@ -292,10 +324,11 @@ rocksdb_native__on_close(rocksdb_close_t *handle, int status) {
|
|
|
292
324
|
err = js_get_reference_value(env, req->on_close, cb);
|
|
293
325
|
assert(err == 0);
|
|
294
326
|
|
|
295
|
-
db->ctx.reset();
|
|
296
327
|
req->on_close.reset();
|
|
297
328
|
req->ctx.reset();
|
|
298
329
|
|
|
330
|
+
db->ctx.reset();
|
|
331
|
+
|
|
299
332
|
js_call_function_with_checkpoint(env, cb, ctx);
|
|
300
333
|
|
|
301
334
|
err = js_close_handle_scope(env, scope);
|
|
@@ -323,7 +356,7 @@ rocksdb_native__on_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
|
323
356
|
req->env = env;
|
|
324
357
|
req->handle.data = req;
|
|
325
358
|
|
|
326
|
-
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_close);
|
|
359
|
+
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_idle, rocksdb_native__on_close);
|
|
327
360
|
assert(err == 0);
|
|
328
361
|
}
|
|
329
362
|
|
|
@@ -358,6 +391,9 @@ rocksdb_native_init(
|
|
|
358
391
|
db->closing = false;
|
|
359
392
|
db->exiting = false;
|
|
360
393
|
|
|
394
|
+
new (&db->column_families) std::set<rocksdb_native_column_family_t *>();
|
|
395
|
+
new (&db->snapshots) std::set<rocksdb_native_snapshot_t *>();
|
|
396
|
+
|
|
361
397
|
db->options = (rocksdb_options_t) {
|
|
362
398
|
3,
|
|
363
399
|
read_only,
|
|
@@ -416,7 +452,7 @@ rocksdb_native_open(
|
|
|
416
452
|
|
|
417
453
|
memcpy(&column_families[i], &column_family->descriptor, sizeof(rocksdb_column_family_descriptor_t));
|
|
418
454
|
|
|
419
|
-
column_family->db =
|
|
455
|
+
column_family->db = db;
|
|
420
456
|
}
|
|
421
457
|
|
|
422
458
|
auto handles = new rocksdb_column_family_t *[len];
|
|
@@ -432,7 +468,7 @@ rocksdb_native_open(
|
|
|
432
468
|
|
|
433
469
|
db->options.lock = lock;
|
|
434
470
|
|
|
435
|
-
err = rocksdb_open(&db->handle, &req->handle, path, &db->options, column_families, handles, len, rocksdb_native__on_open);
|
|
471
|
+
err = rocksdb_open(&db->handle, &req->handle, path, &db->options, column_families, handles, len, nullptr, rocksdb_native__on_open);
|
|
436
472
|
|
|
437
473
|
if (err < 0) {
|
|
438
474
|
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
@@ -483,7 +519,7 @@ rocksdb_native_close(
|
|
|
483
519
|
req->env = env;
|
|
484
520
|
req->handle.data = req;
|
|
485
521
|
|
|
486
|
-
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_close);
|
|
522
|
+
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_idle, rocksdb_native__on_close);
|
|
487
523
|
|
|
488
524
|
if (err < 0) {
|
|
489
525
|
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
@@ -666,20 +702,6 @@ rocksdb_native_resume(
|
|
|
666
702
|
return handle;
|
|
667
703
|
}
|
|
668
704
|
|
|
669
|
-
static void
|
|
670
|
-
rocksdb_native__on_column_family_teardown(void *data) {
|
|
671
|
-
int err;
|
|
672
|
-
|
|
673
|
-
auto column_family = reinterpret_cast<rocksdb_native_column_family_t *>(data);
|
|
674
|
-
|
|
675
|
-
auto env = column_family->env;
|
|
676
|
-
|
|
677
|
-
err = rocksdb_column_family_destroy(column_family->db, column_family->handle);
|
|
678
|
-
assert(err == 0);
|
|
679
|
-
|
|
680
|
-
column_family->ctx.reset();
|
|
681
|
-
}
|
|
682
|
-
|
|
683
705
|
static js_arraybuffer_t
|
|
684
706
|
rocksdb_native_column_family_init(
|
|
685
707
|
js_env_t *env,
|
|
@@ -734,7 +756,6 @@ rocksdb_native_column_family_init(
|
|
|
734
756
|
err = js_create_arraybuffer(env, column_family, handle);
|
|
735
757
|
assert(err == 0);
|
|
736
758
|
|
|
737
|
-
column_family->env = env;
|
|
738
759
|
column_family->db = nullptr;
|
|
739
760
|
column_family->handle = nullptr;
|
|
740
761
|
|
|
@@ -774,15 +795,14 @@ rocksdb_native_column_family_destroy(
|
|
|
774
795
|
|
|
775
796
|
if (column_family->handle == nullptr) return;
|
|
776
797
|
|
|
777
|
-
err = rocksdb_column_family_destroy(column_family->db, column_family->handle);
|
|
798
|
+
err = rocksdb_column_family_destroy(&column_family->db->handle, column_family->handle);
|
|
778
799
|
assert(err == 0);
|
|
779
800
|
|
|
780
|
-
|
|
781
|
-
assert(err == 0);
|
|
801
|
+
column_family->handle = nullptr;
|
|
782
802
|
|
|
783
|
-
column_family->
|
|
803
|
+
column_family->db->column_families.erase(column_family);
|
|
784
804
|
|
|
785
|
-
column_family->
|
|
805
|
+
column_family->ctx.reset();
|
|
786
806
|
}
|
|
787
807
|
|
|
788
808
|
static js_arraybuffer_t
|
|
@@ -950,7 +970,7 @@ rocksdb_native_iterator_open(
|
|
|
950
970
|
js_typedarray_t<> lte,
|
|
951
971
|
bool reverse,
|
|
952
972
|
bool keys_only,
|
|
953
|
-
std::optional<
|
|
973
|
+
std::optional<js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1>> snapshot,
|
|
954
974
|
js_receiver_t ctx,
|
|
955
975
|
rocksdb_native_on_iterator_open_t on_open,
|
|
956
976
|
rocksdb_native_on_iterator_close_t on_close,
|
|
@@ -978,10 +998,7 @@ rocksdb_native_iterator_open(
|
|
|
978
998
|
.keys_only = keys_only
|
|
979
999
|
};
|
|
980
1000
|
|
|
981
|
-
if (snapshot)
|
|
982
|
-
err = js_get_arraybuffer_info(env, snapshot.value(), options.snapshot);
|
|
983
|
-
assert(err == 0);
|
|
984
|
-
}
|
|
1001
|
+
if (snapshot) options.snapshot = &snapshot.value()->handle;
|
|
985
1002
|
|
|
986
1003
|
err = rocksdb_iterator_open(&db->handle, &req->handle, column_family->handle, range, &options, rocksdb_native__on_iterator_open);
|
|
987
1004
|
|
|
@@ -1255,7 +1272,7 @@ rocksdb_native_read(
|
|
|
1255
1272
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
1256
1273
|
js_arraybuffer_span_of_t<rocksdb_native_read_batch_t, 1> req,
|
|
1257
1274
|
js_array_t operations,
|
|
1258
|
-
std::optional<
|
|
1275
|
+
std::optional<js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1>> snapshot,
|
|
1259
1276
|
bool async_io,
|
|
1260
1277
|
bool fill_cache,
|
|
1261
1278
|
js_receiver_t ctx,
|
|
@@ -1310,10 +1327,7 @@ rocksdb_native_read(
|
|
|
1310
1327
|
.fill_cache = fill_cache
|
|
1311
1328
|
};
|
|
1312
1329
|
|
|
1313
|
-
if (snapshot)
|
|
1314
|
-
err = js_get_arraybuffer_info(env, snapshot.value(), options.snapshot);
|
|
1315
|
-
assert(err == 0);
|
|
1316
|
-
}
|
|
1330
|
+
if (snapshot) options.snapshot = &snapshot.value()->handle;
|
|
1317
1331
|
|
|
1318
1332
|
err = rocksdb_read(&db->handle, &req->handle, req->reads, len, &options, rocksdb_native__on_read);
|
|
1319
1333
|
|
|
@@ -1800,13 +1814,6 @@ rocksdb_native_approximate_size(
|
|
|
1800
1814
|
return handle;
|
|
1801
1815
|
}
|
|
1802
1816
|
|
|
1803
|
-
static void
|
|
1804
|
-
rocksdb_native__on_snapshot_teardown(void *data) {
|
|
1805
|
-
auto snapshot = reinterpret_cast<rocksdb_native_snapshot_t *>(data);
|
|
1806
|
-
|
|
1807
|
-
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1817
|
static js_arraybuffer_t
|
|
1811
1818
|
rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_t, 1> db) {
|
|
1812
1819
|
int err;
|
|
@@ -1817,6 +1824,8 @@ rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_n
|
|
|
1817
1824
|
err = js_create_arraybuffer(env, snapshot, handle);
|
|
1818
1825
|
assert(err == 0);
|
|
1819
1826
|
|
|
1827
|
+
snapshot->db = db;
|
|
1828
|
+
|
|
1820
1829
|
err = rocksdb_snapshot_create(&db->handle, &snapshot->handle);
|
|
1821
1830
|
|
|
1822
1831
|
if (err < 0) {
|
|
@@ -1826,9 +1835,11 @@ rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_n
|
|
|
1826
1835
|
throw js_pending_exception;
|
|
1827
1836
|
}
|
|
1828
1837
|
|
|
1829
|
-
err =
|
|
1838
|
+
err = js_create_reference(env, handle, snapshot->ctx);
|
|
1830
1839
|
assert(err == 0);
|
|
1831
1840
|
|
|
1841
|
+
db->snapshots.insert(snapshot);
|
|
1842
|
+
|
|
1832
1843
|
return handle;
|
|
1833
1844
|
}
|
|
1834
1845
|
|
|
@@ -1838,8 +1849,9 @@ rocksdb_native_snapshot_destroy(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_
|
|
|
1838
1849
|
|
|
1839
1850
|
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1840
1851
|
|
|
1841
|
-
|
|
1842
|
-
|
|
1852
|
+
snapshot->db->snapshots.erase(snapshot);
|
|
1853
|
+
|
|
1854
|
+
snapshot->ctx.reset();
|
|
1843
1855
|
}
|
|
1844
1856
|
|
|
1845
1857
|
static js_value_t *
|
package/lib/state.js
CHANGED
|
@@ -28,8 +28,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
28
28
|
skipStatsUpdateOnOpen = false,
|
|
29
29
|
useDirectIOForFlushAndCompaction = false,
|
|
30
30
|
maxFileOpeningThreads = 16,
|
|
31
|
-
lock = null
|
|
32
|
-
preopen = null
|
|
31
|
+
lock = null
|
|
33
32
|
} = opts
|
|
34
33
|
|
|
35
34
|
this.path = path
|
|
@@ -47,7 +46,6 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
47
46
|
this._updatingSignal = new SignalPromise()
|
|
48
47
|
this._columnsFlushed = false
|
|
49
48
|
this._lock = lock
|
|
50
|
-
this._preopen = preopen
|
|
51
49
|
this._readBatches = []
|
|
52
50
|
this._writeBatches = []
|
|
53
51
|
|
|
@@ -142,8 +140,6 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
142
140
|
|
|
143
141
|
if (this._lock) await this._lock.ready()
|
|
144
142
|
|
|
145
|
-
if (this._preopen) await this._preopen
|
|
146
|
-
|
|
147
143
|
const req = { resolve: null, reject: null, handle: null }
|
|
148
144
|
|
|
149
145
|
const promise = new Promise((resolve, reject) => {
|
package/package.json
CHANGED
|
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
|