rocksdb-native 3.11.1 → 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 +68 -57
- 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;
|
|
@@ -324,7 +356,7 @@ rocksdb_native__on_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
|
324
356
|
req->env = env;
|
|
325
357
|
req->handle.data = req;
|
|
326
358
|
|
|
327
|
-
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);
|
|
328
360
|
assert(err == 0);
|
|
329
361
|
}
|
|
330
362
|
|
|
@@ -359,6 +391,9 @@ rocksdb_native_init(
|
|
|
359
391
|
db->closing = false;
|
|
360
392
|
db->exiting = false;
|
|
361
393
|
|
|
394
|
+
new (&db->column_families) std::set<rocksdb_native_column_family_t *>();
|
|
395
|
+
new (&db->snapshots) std::set<rocksdb_native_snapshot_t *>();
|
|
396
|
+
|
|
362
397
|
db->options = (rocksdb_options_t) {
|
|
363
398
|
3,
|
|
364
399
|
read_only,
|
|
@@ -417,7 +452,7 @@ rocksdb_native_open(
|
|
|
417
452
|
|
|
418
453
|
memcpy(&column_families[i], &column_family->descriptor, sizeof(rocksdb_column_family_descriptor_t));
|
|
419
454
|
|
|
420
|
-
column_family->db =
|
|
455
|
+
column_family->db = db;
|
|
421
456
|
}
|
|
422
457
|
|
|
423
458
|
auto handles = new rocksdb_column_family_t *[len];
|
|
@@ -433,7 +468,7 @@ rocksdb_native_open(
|
|
|
433
468
|
|
|
434
469
|
db->options.lock = lock;
|
|
435
470
|
|
|
436
|
-
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);
|
|
437
472
|
|
|
438
473
|
if (err < 0) {
|
|
439
474
|
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
@@ -484,7 +519,7 @@ rocksdb_native_close(
|
|
|
484
519
|
req->env = env;
|
|
485
520
|
req->handle.data = req;
|
|
486
521
|
|
|
487
|
-
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);
|
|
488
523
|
|
|
489
524
|
if (err < 0) {
|
|
490
525
|
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
@@ -667,20 +702,6 @@ rocksdb_native_resume(
|
|
|
667
702
|
return handle;
|
|
668
703
|
}
|
|
669
704
|
|
|
670
|
-
static void
|
|
671
|
-
rocksdb_native__on_column_family_teardown(void *data) {
|
|
672
|
-
int err;
|
|
673
|
-
|
|
674
|
-
auto column_family = reinterpret_cast<rocksdb_native_column_family_t *>(data);
|
|
675
|
-
|
|
676
|
-
auto env = column_family->env;
|
|
677
|
-
|
|
678
|
-
err = rocksdb_column_family_destroy(column_family->db, column_family->handle);
|
|
679
|
-
assert(err == 0);
|
|
680
|
-
|
|
681
|
-
column_family->ctx.reset();
|
|
682
|
-
}
|
|
683
|
-
|
|
684
705
|
static js_arraybuffer_t
|
|
685
706
|
rocksdb_native_column_family_init(
|
|
686
707
|
js_env_t *env,
|
|
@@ -735,7 +756,6 @@ rocksdb_native_column_family_init(
|
|
|
735
756
|
err = js_create_arraybuffer(env, column_family, handle);
|
|
736
757
|
assert(err == 0);
|
|
737
758
|
|
|
738
|
-
column_family->env = env;
|
|
739
759
|
column_family->db = nullptr;
|
|
740
760
|
column_family->handle = nullptr;
|
|
741
761
|
|
|
@@ -775,15 +795,14 @@ rocksdb_native_column_family_destroy(
|
|
|
775
795
|
|
|
776
796
|
if (column_family->handle == nullptr) return;
|
|
777
797
|
|
|
778
|
-
err = rocksdb_column_family_destroy(column_family->db, column_family->handle);
|
|
798
|
+
err = rocksdb_column_family_destroy(&column_family->db->handle, column_family->handle);
|
|
779
799
|
assert(err == 0);
|
|
780
800
|
|
|
781
|
-
|
|
782
|
-
assert(err == 0);
|
|
801
|
+
column_family->handle = nullptr;
|
|
783
802
|
|
|
784
|
-
column_family->
|
|
803
|
+
column_family->db->column_families.erase(column_family);
|
|
785
804
|
|
|
786
|
-
column_family->
|
|
805
|
+
column_family->ctx.reset();
|
|
787
806
|
}
|
|
788
807
|
|
|
789
808
|
static js_arraybuffer_t
|
|
@@ -951,7 +970,7 @@ rocksdb_native_iterator_open(
|
|
|
951
970
|
js_typedarray_t<> lte,
|
|
952
971
|
bool reverse,
|
|
953
972
|
bool keys_only,
|
|
954
|
-
std::optional<
|
|
973
|
+
std::optional<js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1>> snapshot,
|
|
955
974
|
js_receiver_t ctx,
|
|
956
975
|
rocksdb_native_on_iterator_open_t on_open,
|
|
957
976
|
rocksdb_native_on_iterator_close_t on_close,
|
|
@@ -979,10 +998,7 @@ rocksdb_native_iterator_open(
|
|
|
979
998
|
.keys_only = keys_only
|
|
980
999
|
};
|
|
981
1000
|
|
|
982
|
-
if (snapshot)
|
|
983
|
-
err = js_get_arraybuffer_info(env, snapshot.value(), options.snapshot);
|
|
984
|
-
assert(err == 0);
|
|
985
|
-
}
|
|
1001
|
+
if (snapshot) options.snapshot = &snapshot.value()->handle;
|
|
986
1002
|
|
|
987
1003
|
err = rocksdb_iterator_open(&db->handle, &req->handle, column_family->handle, range, &options, rocksdb_native__on_iterator_open);
|
|
988
1004
|
|
|
@@ -1256,7 +1272,7 @@ rocksdb_native_read(
|
|
|
1256
1272
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
1257
1273
|
js_arraybuffer_span_of_t<rocksdb_native_read_batch_t, 1> req,
|
|
1258
1274
|
js_array_t operations,
|
|
1259
|
-
std::optional<
|
|
1275
|
+
std::optional<js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1>> snapshot,
|
|
1260
1276
|
bool async_io,
|
|
1261
1277
|
bool fill_cache,
|
|
1262
1278
|
js_receiver_t ctx,
|
|
@@ -1311,10 +1327,7 @@ rocksdb_native_read(
|
|
|
1311
1327
|
.fill_cache = fill_cache
|
|
1312
1328
|
};
|
|
1313
1329
|
|
|
1314
|
-
if (snapshot)
|
|
1315
|
-
err = js_get_arraybuffer_info(env, snapshot.value(), options.snapshot);
|
|
1316
|
-
assert(err == 0);
|
|
1317
|
-
}
|
|
1330
|
+
if (snapshot) options.snapshot = &snapshot.value()->handle;
|
|
1318
1331
|
|
|
1319
1332
|
err = rocksdb_read(&db->handle, &req->handle, req->reads, len, &options, rocksdb_native__on_read);
|
|
1320
1333
|
|
|
@@ -1801,13 +1814,6 @@ rocksdb_native_approximate_size(
|
|
|
1801
1814
|
return handle;
|
|
1802
1815
|
}
|
|
1803
1816
|
|
|
1804
|
-
static void
|
|
1805
|
-
rocksdb_native__on_snapshot_teardown(void *data) {
|
|
1806
|
-
auto snapshot = reinterpret_cast<rocksdb_native_snapshot_t *>(data);
|
|
1807
|
-
|
|
1808
|
-
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
1817
|
static js_arraybuffer_t
|
|
1812
1818
|
rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_t, 1> db) {
|
|
1813
1819
|
int err;
|
|
@@ -1818,6 +1824,8 @@ rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_n
|
|
|
1818
1824
|
err = js_create_arraybuffer(env, snapshot, handle);
|
|
1819
1825
|
assert(err == 0);
|
|
1820
1826
|
|
|
1827
|
+
snapshot->db = db;
|
|
1828
|
+
|
|
1821
1829
|
err = rocksdb_snapshot_create(&db->handle, &snapshot->handle);
|
|
1822
1830
|
|
|
1823
1831
|
if (err < 0) {
|
|
@@ -1827,9 +1835,11 @@ rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_n
|
|
|
1827
1835
|
throw js_pending_exception;
|
|
1828
1836
|
}
|
|
1829
1837
|
|
|
1830
|
-
err =
|
|
1838
|
+
err = js_create_reference(env, handle, snapshot->ctx);
|
|
1831
1839
|
assert(err == 0);
|
|
1832
1840
|
|
|
1841
|
+
db->snapshots.insert(snapshot);
|
|
1842
|
+
|
|
1833
1843
|
return handle;
|
|
1834
1844
|
}
|
|
1835
1845
|
|
|
@@ -1839,8 +1849,9 @@ rocksdb_native_snapshot_destroy(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_
|
|
|
1839
1849
|
|
|
1840
1850
|
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1841
1851
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1852
|
+
snapshot->db->snapshots.erase(snapshot);
|
|
1853
|
+
|
|
1854
|
+
snapshot->ctx.reset();
|
|
1844
1855
|
}
|
|
1845
1856
|
|
|
1846
1857
|
static js_value_t *
|
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
|