rocksdb-native 3.9.1 → 3.9.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/binding.cc +273 -200
- package/lib/state.js +12 -6
- 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/binding.cc
CHANGED
|
@@ -6,26 +6,20 @@
|
|
|
6
6
|
#include <stdlib.h>
|
|
7
7
|
#include <string.h>
|
|
8
8
|
#include <utf.h>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
using
|
|
12
|
-
using
|
|
13
|
-
using
|
|
14
|
-
using
|
|
15
|
-
using
|
|
16
|
-
using
|
|
17
|
-
using
|
|
18
|
-
using
|
|
19
|
-
using
|
|
20
|
-
using
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
std::optional<js_string_t>,
|
|
24
|
-
std::vector<js_arraybuffer_t>,
|
|
25
|
-
std::vector<js_arraybuffer_t>>;
|
|
26
|
-
using cb_on_compact_range_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
27
|
-
using cb_on_approximate_size_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>, uint64_t>;
|
|
28
|
-
}; // namespace
|
|
9
|
+
#include <uv.h>
|
|
10
|
+
|
|
11
|
+
using rocksdb_native_on_open_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
12
|
+
using rocksdb_native_on_close_t = js_function_t<void, js_receiver_t>;
|
|
13
|
+
using rocksdb_native_on_suspend_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
14
|
+
using rocksdb_native_on_resume_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
15
|
+
using rocksdb_native_on_flush_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
16
|
+
using rocksdb_native_on_write_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
17
|
+
using rocksdb_native_on_read_t = js_function_t<void, js_receiver_t, js_array_t, js_array_t>;
|
|
18
|
+
using rocksdb_native_on_iterator_open_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
19
|
+
using rocksdb_native_on_iterator_close_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
20
|
+
using rocksdb_native_on_iterator_read_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>, std::vector<js_arraybuffer_t>, std::vector<js_arraybuffer_t>>;
|
|
21
|
+
using rocksdb_native_on_compact_range_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>>;
|
|
22
|
+
using rocksdb_native_on_approximate_size_t = js_function_t<void, js_receiver_t, std::optional<js_string_t>, uint64_t>;
|
|
29
23
|
|
|
30
24
|
struct rocksdb_native_column_family_t {
|
|
31
25
|
rocksdb_column_family_t *handle;
|
|
@@ -55,7 +49,7 @@ struct rocksdb_native_open_t {
|
|
|
55
49
|
|
|
56
50
|
js_env_t *env;
|
|
57
51
|
js_persistent_t<js_receiver_t> ctx;
|
|
58
|
-
js_persistent_t<
|
|
52
|
+
js_persistent_t<rocksdb_native_on_open_t> on_open;
|
|
59
53
|
|
|
60
54
|
js_persistent_t<js_array_t> column_families;
|
|
61
55
|
};
|
|
@@ -65,7 +59,7 @@ struct rocksdb_native_close_t {
|
|
|
65
59
|
|
|
66
60
|
js_env_t *env;
|
|
67
61
|
js_persistent_t<js_receiver_t> ctx;
|
|
68
|
-
js_persistent_t<
|
|
62
|
+
js_persistent_t<rocksdb_native_on_close_t> on_close;
|
|
69
63
|
};
|
|
70
64
|
|
|
71
65
|
struct rocksdb_native_suspend_t {
|
|
@@ -73,7 +67,7 @@ struct rocksdb_native_suspend_t {
|
|
|
73
67
|
|
|
74
68
|
js_env_t *env;
|
|
75
69
|
js_persistent_t<js_receiver_t> ctx;
|
|
76
|
-
js_persistent_t<
|
|
70
|
+
js_persistent_t<rocksdb_native_on_suspend_t> on_suspend;
|
|
77
71
|
};
|
|
78
72
|
|
|
79
73
|
struct rocksdb_native_resume_t {
|
|
@@ -81,7 +75,7 @@ struct rocksdb_native_resume_t {
|
|
|
81
75
|
|
|
82
76
|
js_env_t *env;
|
|
83
77
|
js_persistent_t<js_receiver_t> ctx;
|
|
84
|
-
js_persistent_t<
|
|
78
|
+
js_persistent_t<rocksdb_native_on_resume_t> on_resume;
|
|
85
79
|
};
|
|
86
80
|
|
|
87
81
|
struct rocksdb_native_iterator_t {
|
|
@@ -92,9 +86,9 @@ struct rocksdb_native_iterator_t {
|
|
|
92
86
|
|
|
93
87
|
js_env_t *env;
|
|
94
88
|
js_persistent_t<js_receiver_t> ctx;
|
|
95
|
-
js_persistent_t<
|
|
96
|
-
js_persistent_t<
|
|
97
|
-
js_persistent_t<
|
|
89
|
+
js_persistent_t<rocksdb_native_on_iterator_open_t> on_open;
|
|
90
|
+
js_persistent_t<rocksdb_native_on_iterator_close_t> on_close;
|
|
91
|
+
js_persistent_t<rocksdb_native_on_iterator_read_t> on_read;
|
|
98
92
|
|
|
99
93
|
bool active;
|
|
100
94
|
bool exiting;
|
|
@@ -111,7 +105,7 @@ struct rocksdb_native_read_batch_t {
|
|
|
111
105
|
|
|
112
106
|
js_env_t *env;
|
|
113
107
|
js_persistent_t<js_receiver_t> ctx;
|
|
114
|
-
js_persistent_t<
|
|
108
|
+
js_persistent_t<rocksdb_native_on_read_t> on_read;
|
|
115
109
|
};
|
|
116
110
|
|
|
117
111
|
struct rocksdb_native_write_batch_t {
|
|
@@ -123,7 +117,7 @@ struct rocksdb_native_write_batch_t {
|
|
|
123
117
|
|
|
124
118
|
js_env_t *env;
|
|
125
119
|
js_persistent_t<js_receiver_t> ctx;
|
|
126
|
-
js_persistent_t<
|
|
120
|
+
js_persistent_t<rocksdb_native_on_write_t> on_write;
|
|
127
121
|
};
|
|
128
122
|
|
|
129
123
|
struct rocksdb_native_flush_t {
|
|
@@ -131,7 +125,7 @@ struct rocksdb_native_flush_t {
|
|
|
131
125
|
|
|
132
126
|
js_env_t *env;
|
|
133
127
|
js_persistent_t<js_receiver_t> ctx;
|
|
134
|
-
js_persistent_t<
|
|
128
|
+
js_persistent_t<rocksdb_native_on_flush_t> on_flush;
|
|
135
129
|
|
|
136
130
|
js_persistent_t<rocksdb_native_column_family_t> column_family;
|
|
137
131
|
};
|
|
@@ -145,7 +139,7 @@ struct rocksdb_native_compact_range_t {
|
|
|
145
139
|
|
|
146
140
|
js_env_t *env;
|
|
147
141
|
js_persistent_t<js_receiver_t> ctx;
|
|
148
|
-
js_persistent_t<
|
|
142
|
+
js_persistent_t<rocksdb_native_on_compact_range_t> on_compact_range;
|
|
149
143
|
};
|
|
150
144
|
|
|
151
145
|
struct rocksdb_native_approximate_size_t {
|
|
@@ -153,7 +147,7 @@ struct rocksdb_native_approximate_size_t {
|
|
|
153
147
|
|
|
154
148
|
js_env_t *env;
|
|
155
149
|
js_persistent_t<js_receiver_t> ctx;
|
|
156
|
-
js_persistent_t<
|
|
150
|
+
js_persistent_t<rocksdb_native_on_approximate_size_t> on_approximate_size;
|
|
157
151
|
};
|
|
158
152
|
|
|
159
153
|
static void
|
|
@@ -174,11 +168,11 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
174
168
|
|
|
175
169
|
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
176
170
|
|
|
177
|
-
|
|
171
|
+
auto env = req->env;
|
|
178
172
|
|
|
179
|
-
|
|
173
|
+
auto descriptors = handle->column_families;
|
|
180
174
|
|
|
181
|
-
|
|
175
|
+
auto handles = handle->handles;
|
|
182
176
|
|
|
183
177
|
if (db->exiting) {
|
|
184
178
|
req->on_open.reset();
|
|
@@ -192,7 +186,7 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
192
186
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
193
187
|
assert(err == 0);
|
|
194
188
|
|
|
195
|
-
|
|
189
|
+
rocksdb_native_on_open_t cb;
|
|
196
190
|
err = js_get_reference_value(env, req->on_open, cb);
|
|
197
191
|
assert(err == 0);
|
|
198
192
|
|
|
@@ -215,7 +209,6 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
215
209
|
|
|
216
210
|
if (req->handle.error == NULL) {
|
|
217
211
|
std::vector<js_arraybuffer_t> elements;
|
|
218
|
-
|
|
219
212
|
err = js_get_array_elements(env, column_families, elements);
|
|
220
213
|
assert(err == 0);
|
|
221
214
|
|
|
@@ -233,7 +226,7 @@ rocksdb_native__on_open(rocksdb_open_t *handle, int status) {
|
|
|
233
226
|
err = js_create_reference(env, ctx, column_family->ctx);
|
|
234
227
|
assert(err == 0);
|
|
235
228
|
|
|
236
|
-
err = js_add_teardown_callback(env, rocksdb_native__on_column_family_teardown,
|
|
229
|
+
err = js_add_teardown_callback(env, rocksdb_native__on_column_family_teardown, column_family);
|
|
237
230
|
assert(err == 0);
|
|
238
231
|
}
|
|
239
232
|
}
|
|
@@ -254,13 +247,13 @@ rocksdb_native__on_close(rocksdb_close_t *handle, int status) {
|
|
|
254
247
|
|
|
255
248
|
assert(status == 0);
|
|
256
249
|
|
|
257
|
-
|
|
250
|
+
auto req = reinterpret_cast<rocksdb_native_close_t *>(handle->data);
|
|
258
251
|
|
|
259
|
-
|
|
252
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
260
253
|
|
|
261
|
-
|
|
254
|
+
auto env = req->env;
|
|
262
255
|
|
|
263
|
-
|
|
256
|
+
auto teardown = db->teardown;
|
|
264
257
|
|
|
265
258
|
if (db->exiting) {
|
|
266
259
|
db->ctx.reset();
|
|
@@ -280,7 +273,7 @@ rocksdb_native__on_close(rocksdb_close_t *handle, int status) {
|
|
|
280
273
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
281
274
|
assert(err == 0);
|
|
282
275
|
|
|
283
|
-
|
|
276
|
+
rocksdb_native_on_close_t cb;
|
|
284
277
|
err = js_get_reference_value(env, req->on_close, cb);
|
|
285
278
|
assert(err == 0);
|
|
286
279
|
|
|
@@ -302,9 +295,9 @@ static void
|
|
|
302
295
|
rocksdb_native__on_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
303
296
|
int err;
|
|
304
297
|
|
|
305
|
-
|
|
298
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(data);
|
|
306
299
|
|
|
307
|
-
|
|
300
|
+
auto env = db->env;
|
|
308
301
|
|
|
309
302
|
db->exiting = true;
|
|
310
303
|
|
|
@@ -313,7 +306,7 @@ rocksdb_native__on_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
|
313
306
|
auto req = reinterpret_cast<rocksdb_native_close_t *>(malloc(sizeof(rocksdb_native_close_t)));
|
|
314
307
|
|
|
315
308
|
req->env = env;
|
|
316
|
-
req->handle.data =
|
|
309
|
+
req->handle.data = req;
|
|
317
310
|
|
|
318
311
|
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_close);
|
|
319
312
|
assert(err == 0);
|
|
@@ -366,7 +359,13 @@ rocksdb_native_init(
|
|
|
366
359
|
};
|
|
367
360
|
|
|
368
361
|
err = rocksdb_init(loop, &db->handle);
|
|
369
|
-
|
|
362
|
+
|
|
363
|
+
if (err < 0) {
|
|
364
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
365
|
+
assert(err == 0);
|
|
366
|
+
|
|
367
|
+
throw js_pending_exception;
|
|
368
|
+
}
|
|
370
369
|
|
|
371
370
|
return handle;
|
|
372
371
|
}
|
|
@@ -379,12 +378,11 @@ rocksdb_native_open(
|
|
|
379
378
|
char *path,
|
|
380
379
|
js_array_t column_families_array,
|
|
381
380
|
js_receiver_t ctx,
|
|
382
|
-
|
|
381
|
+
rocksdb_native_on_open_t on_open
|
|
383
382
|
) {
|
|
384
383
|
int err;
|
|
385
384
|
|
|
386
385
|
std::vector<js_arraybuffer_t> elements;
|
|
387
|
-
|
|
388
386
|
err = js_get_array_elements(env, column_families_array, elements);
|
|
389
387
|
assert(err == 0);
|
|
390
388
|
|
|
@@ -415,6 +413,15 @@ rocksdb_native_open(
|
|
|
415
413
|
req->env = env;
|
|
416
414
|
req->handle.data = req;
|
|
417
415
|
|
|
416
|
+
err = rocksdb_open(&db->handle, &req->handle, path, &db->options, column_families, handles, len, rocksdb_native__on_open);
|
|
417
|
+
|
|
418
|
+
if (err < 0) {
|
|
419
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
420
|
+
assert(err == 0);
|
|
421
|
+
|
|
422
|
+
throw js_pending_exception;
|
|
423
|
+
}
|
|
424
|
+
|
|
418
425
|
err = js_create_reference(env, self, db->ctx);
|
|
419
426
|
assert(err == 0);
|
|
420
427
|
|
|
@@ -427,10 +434,7 @@ rocksdb_native_open(
|
|
|
427
434
|
err = js_create_reference(env, column_families_array, req->column_families);
|
|
428
435
|
assert(err == 0);
|
|
429
436
|
|
|
430
|
-
err =
|
|
431
|
-
assert(err == 0);
|
|
432
|
-
|
|
433
|
-
err = js_add_deferred_teardown_callback(env, rocksdb_native__on_teardown, (void *) db, &db->teardown);
|
|
437
|
+
err = js_add_deferred_teardown_callback(env, rocksdb_native__on_teardown, db, &db->teardown);
|
|
434
438
|
assert(err == 0);
|
|
435
439
|
|
|
436
440
|
return handle;
|
|
@@ -441,7 +445,7 @@ rocksdb_native_close(
|
|
|
441
445
|
js_env_t *env,
|
|
442
446
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
443
447
|
js_receiver_t ctx,
|
|
444
|
-
|
|
448
|
+
rocksdb_native_on_close_t on_close
|
|
445
449
|
) {
|
|
446
450
|
int err;
|
|
447
451
|
|
|
@@ -452,7 +456,16 @@ rocksdb_native_close(
|
|
|
452
456
|
assert(err == 0);
|
|
453
457
|
|
|
454
458
|
req->env = env;
|
|
455
|
-
req->handle.data =
|
|
459
|
+
req->handle.data = req;
|
|
460
|
+
|
|
461
|
+
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_close);
|
|
462
|
+
|
|
463
|
+
if (err < 0) {
|
|
464
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
465
|
+
assert(err == 0);
|
|
466
|
+
|
|
467
|
+
throw js_pending_exception;
|
|
468
|
+
}
|
|
456
469
|
|
|
457
470
|
err = js_create_reference(env, ctx, req->ctx);
|
|
458
471
|
assert(err == 0);
|
|
@@ -462,9 +475,6 @@ rocksdb_native_close(
|
|
|
462
475
|
|
|
463
476
|
db->closing = true;
|
|
464
477
|
|
|
465
|
-
err = rocksdb_close(&db->handle, &req->handle, rocksdb_native__on_close);
|
|
466
|
-
assert(err == 0);
|
|
467
|
-
|
|
468
478
|
return handle;
|
|
469
479
|
}
|
|
470
480
|
|
|
@@ -474,13 +484,13 @@ rocksdb_native__on_suspend(rocksdb_suspend_t *handle, int status) {
|
|
|
474
484
|
|
|
475
485
|
assert(status == 0);
|
|
476
486
|
|
|
477
|
-
|
|
487
|
+
auto req = reinterpret_cast<rocksdb_native_suspend_t *>(handle->data);
|
|
478
488
|
|
|
479
|
-
|
|
489
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
480
490
|
|
|
481
|
-
|
|
491
|
+
auto env = req->env;
|
|
482
492
|
|
|
483
|
-
|
|
493
|
+
auto teardown = db->teardown;
|
|
484
494
|
|
|
485
495
|
if (db->exiting) {
|
|
486
496
|
req->on_suspend.reset();
|
|
@@ -494,7 +504,7 @@ rocksdb_native__on_suspend(rocksdb_suspend_t *handle, int status) {
|
|
|
494
504
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
495
505
|
assert(err == 0);
|
|
496
506
|
|
|
497
|
-
|
|
507
|
+
rocksdb_native_on_suspend_t cb;
|
|
498
508
|
err = js_get_reference_value(env, req->on_suspend, cb);
|
|
499
509
|
assert(err == 0);
|
|
500
510
|
|
|
@@ -517,7 +527,7 @@ rocksdb_native_suspend(
|
|
|
517
527
|
js_env_t *env,
|
|
518
528
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
519
529
|
js_receiver_t ctx,
|
|
520
|
-
|
|
530
|
+
rocksdb_native_on_suspend_t on_suspend
|
|
521
531
|
) {
|
|
522
532
|
int err;
|
|
523
533
|
|
|
@@ -528,7 +538,16 @@ rocksdb_native_suspend(
|
|
|
528
538
|
assert(err == 0);
|
|
529
539
|
|
|
530
540
|
req->env = env;
|
|
531
|
-
req->handle.data =
|
|
541
|
+
req->handle.data = req;
|
|
542
|
+
|
|
543
|
+
err = rocksdb_suspend(&db->handle, &req->handle, rocksdb_native__on_suspend);
|
|
544
|
+
|
|
545
|
+
if (err < 0) {
|
|
546
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
547
|
+
assert(err == 0);
|
|
548
|
+
|
|
549
|
+
throw js_pending_exception;
|
|
550
|
+
}
|
|
532
551
|
|
|
533
552
|
err = js_create_reference(env, ctx, req->ctx);
|
|
534
553
|
assert(err == 0);
|
|
@@ -536,9 +555,6 @@ rocksdb_native_suspend(
|
|
|
536
555
|
err = js_create_reference(env, on_suspend, req->on_suspend);
|
|
537
556
|
assert(err == 0);
|
|
538
557
|
|
|
539
|
-
err = rocksdb_suspend(&db->handle, &req->handle, rocksdb_native__on_suspend);
|
|
540
|
-
assert(err == 0);
|
|
541
|
-
|
|
542
558
|
return handle;
|
|
543
559
|
}
|
|
544
560
|
|
|
@@ -548,13 +564,13 @@ rocksdb_native__on_resume(rocksdb_resume_t *handle, int status) {
|
|
|
548
564
|
|
|
549
565
|
assert(status == 0);
|
|
550
566
|
|
|
551
|
-
|
|
567
|
+
auto req = reinterpret_cast<rocksdb_native_resume_t *>(handle->data);
|
|
552
568
|
|
|
553
|
-
|
|
569
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
554
570
|
|
|
555
|
-
|
|
571
|
+
auto env = req->env;
|
|
556
572
|
|
|
557
|
-
|
|
573
|
+
auto teardown = db->teardown;
|
|
558
574
|
|
|
559
575
|
if (db->exiting) {
|
|
560
576
|
req->on_resume.reset();
|
|
@@ -568,7 +584,7 @@ rocksdb_native__on_resume(rocksdb_resume_t *handle, int status) {
|
|
|
568
584
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
569
585
|
assert(err == 0);
|
|
570
586
|
|
|
571
|
-
|
|
587
|
+
rocksdb_native_on_resume_t cb;
|
|
572
588
|
err = js_get_reference_value(env, req->on_resume, cb);
|
|
573
589
|
assert(err == 0);
|
|
574
590
|
|
|
@@ -594,7 +610,7 @@ rocksdb_native_resume(
|
|
|
594
610
|
js_env_t *env,
|
|
595
611
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
596
612
|
js_receiver_t ctx,
|
|
597
|
-
|
|
613
|
+
rocksdb_native_on_resume_t on_resume
|
|
598
614
|
) {
|
|
599
615
|
int err;
|
|
600
616
|
|
|
@@ -605,7 +621,16 @@ rocksdb_native_resume(
|
|
|
605
621
|
assert(err == 0);
|
|
606
622
|
|
|
607
623
|
req->env = env;
|
|
608
|
-
req->handle.data =
|
|
624
|
+
req->handle.data = req;
|
|
625
|
+
|
|
626
|
+
err = rocksdb_resume(&db->handle, &req->handle, rocksdb_native__on_resume);
|
|
627
|
+
|
|
628
|
+
if (err < 0) {
|
|
629
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
630
|
+
assert(err == 0);
|
|
631
|
+
|
|
632
|
+
throw js_pending_exception;
|
|
633
|
+
}
|
|
609
634
|
|
|
610
635
|
err = js_create_reference(env, ctx, req->ctx);
|
|
611
636
|
assert(err == 0);
|
|
@@ -613,9 +638,6 @@ rocksdb_native_resume(
|
|
|
613
638
|
err = js_create_reference(env, on_resume, req->on_resume);
|
|
614
639
|
assert(err == 0);
|
|
615
640
|
|
|
616
|
-
err = rocksdb_resume(&db->handle, &req->handle, rocksdb_native__on_resume);
|
|
617
|
-
assert(err == 0);
|
|
618
|
-
|
|
619
641
|
return handle;
|
|
620
642
|
}
|
|
621
643
|
|
|
@@ -623,9 +645,9 @@ static void
|
|
|
623
645
|
rocksdb_native__on_column_family_teardown(void *data) {
|
|
624
646
|
int err;
|
|
625
647
|
|
|
626
|
-
|
|
648
|
+
auto column_family = reinterpret_cast<rocksdb_native_column_family_t *>(data);
|
|
627
649
|
|
|
628
|
-
|
|
650
|
+
auto env = column_family->env;
|
|
629
651
|
|
|
630
652
|
err = rocksdb_column_family_destroy(column_family->db, column_family->handle);
|
|
631
653
|
assert(err == 0);
|
|
@@ -711,7 +733,7 @@ rocksdb_native_column_family_init(
|
|
|
711
733
|
rocksdb_pinning_tier_t(unpartitioned_pinning_tier),
|
|
712
734
|
optimize_filters_for_hits,
|
|
713
735
|
num_levels,
|
|
714
|
-
max_write_buffer_number
|
|
736
|
+
max_write_buffer_number,
|
|
715
737
|
}
|
|
716
738
|
};
|
|
717
739
|
|
|
@@ -772,11 +794,11 @@ rocksdb_native_iterator_buffer(
|
|
|
772
794
|
|
|
773
795
|
size_t offset = 0;
|
|
774
796
|
|
|
775
|
-
req->keys =
|
|
797
|
+
req->keys = reinterpret_cast<rocksdb_slice_t *>(&data[offset]);
|
|
776
798
|
|
|
777
799
|
offset += capacity * sizeof(rocksdb_slice_t);
|
|
778
800
|
|
|
779
|
-
req->values =
|
|
801
|
+
req->values = reinterpret_cast<rocksdb_slice_t *>(&data[offset]);
|
|
780
802
|
|
|
781
803
|
return handle;
|
|
782
804
|
}
|
|
@@ -787,13 +809,13 @@ rocksdb_native__on_iterator_close(rocksdb_iterator_t *handle, int status) {
|
|
|
787
809
|
|
|
788
810
|
assert(status == 0);
|
|
789
811
|
|
|
790
|
-
|
|
812
|
+
auto req = reinterpret_cast<rocksdb_native_iterator_t *>(handle->data);
|
|
791
813
|
|
|
792
814
|
req->active = false;
|
|
793
815
|
|
|
794
|
-
|
|
816
|
+
auto env = req->env;
|
|
795
817
|
|
|
796
|
-
|
|
818
|
+
auto teardown = req->teardown;
|
|
797
819
|
|
|
798
820
|
if (req->exiting) {
|
|
799
821
|
req->on_open.reset();
|
|
@@ -809,7 +831,7 @@ rocksdb_native__on_iterator_close(rocksdb_iterator_t *handle, int status) {
|
|
|
809
831
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
810
832
|
assert(err == 0);
|
|
811
833
|
|
|
812
|
-
|
|
834
|
+
rocksdb_native_on_iterator_close_t cb;
|
|
813
835
|
err = js_get_reference_value(env, req->on_close, cb);
|
|
814
836
|
assert(err == 0);
|
|
815
837
|
|
|
@@ -841,7 +863,7 @@ rocksdb_native__on_iterator_open(rocksdb_iterator_t *handle, int status) {
|
|
|
841
863
|
|
|
842
864
|
assert(status == 0);
|
|
843
865
|
|
|
844
|
-
|
|
866
|
+
auto req = reinterpret_cast<rocksdb_native_iterator_t *>(handle->data);
|
|
845
867
|
|
|
846
868
|
req->active = false;
|
|
847
869
|
|
|
@@ -849,7 +871,7 @@ rocksdb_native__on_iterator_open(rocksdb_iterator_t *handle, int status) {
|
|
|
849
871
|
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
850
872
|
assert(err == 0);
|
|
851
873
|
} else {
|
|
852
|
-
|
|
874
|
+
auto env = req->env;
|
|
853
875
|
|
|
854
876
|
js_handle_scope_t *scope;
|
|
855
877
|
err = js_open_handle_scope(env, &scope);
|
|
@@ -859,7 +881,7 @@ rocksdb_native__on_iterator_open(rocksdb_iterator_t *handle, int status) {
|
|
|
859
881
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
860
882
|
assert(err == 0);
|
|
861
883
|
|
|
862
|
-
|
|
884
|
+
rocksdb_native_on_iterator_open_t cb;
|
|
863
885
|
err = js_get_reference_value(env, req->on_open, cb);
|
|
864
886
|
assert(err == 0);
|
|
865
887
|
|
|
@@ -881,7 +903,7 @@ static void
|
|
|
881
903
|
rocksdb_native__on_iterator_teardown(js_deferred_teardown_t *handle, void *data) {
|
|
882
904
|
int err;
|
|
883
905
|
|
|
884
|
-
|
|
906
|
+
auto req = reinterpret_cast<rocksdb_native_iterator_t *>(data);
|
|
885
907
|
|
|
886
908
|
req->exiting = true;
|
|
887
909
|
|
|
@@ -905,14 +927,12 @@ rocksdb_native_iterator_open(
|
|
|
905
927
|
bool keys_only,
|
|
906
928
|
std::optional<js_arraybuffer_t> snapshot,
|
|
907
929
|
js_receiver_t ctx,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
930
|
+
rocksdb_native_on_iterator_open_t on_open,
|
|
931
|
+
rocksdb_native_on_iterator_close_t on_close,
|
|
932
|
+
rocksdb_native_on_iterator_read_t on_read
|
|
911
933
|
) {
|
|
912
934
|
int err;
|
|
913
935
|
|
|
914
|
-
req->active = true;
|
|
915
|
-
|
|
916
936
|
rocksdb_range_t range;
|
|
917
937
|
|
|
918
938
|
err = js_get_typedarray_info(env, gt, range.gt.data, range.gt.len);
|
|
@@ -938,6 +958,17 @@ rocksdb_native_iterator_open(
|
|
|
938
958
|
assert(err == 0);
|
|
939
959
|
}
|
|
940
960
|
|
|
961
|
+
err = rocksdb_iterator_open(&db->handle, &req->handle, column_family->handle, range, &options, rocksdb_native__on_iterator_open);
|
|
962
|
+
|
|
963
|
+
if (err < 0) {
|
|
964
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
965
|
+
assert(err == 0);
|
|
966
|
+
|
|
967
|
+
throw js_pending_exception;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
req->active = true;
|
|
971
|
+
|
|
941
972
|
err = js_create_reference(env, ctx, req->ctx);
|
|
942
973
|
assert(err == 0);
|
|
943
974
|
|
|
@@ -950,10 +981,7 @@ rocksdb_native_iterator_open(
|
|
|
950
981
|
err = js_create_reference(env, on_read, req->on_read);
|
|
951
982
|
assert(err == 0);
|
|
952
983
|
|
|
953
|
-
err =
|
|
954
|
-
assert(err == 0);
|
|
955
|
-
|
|
956
|
-
err = js_add_deferred_teardown_callback(env, rocksdb_native__on_iterator_teardown, (void *) req, &req->teardown);
|
|
984
|
+
err = js_add_deferred_teardown_callback(env, rocksdb_native__on_iterator_teardown, req, &req->teardown);
|
|
957
985
|
assert(err == 0);
|
|
958
986
|
}
|
|
959
987
|
|
|
@@ -961,10 +989,16 @@ static void
|
|
|
961
989
|
rocksdb_native_iterator_close(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_iterator_t, 1> req) {
|
|
962
990
|
int err;
|
|
963
991
|
|
|
964
|
-
req->active = true;
|
|
965
|
-
|
|
966
992
|
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
967
|
-
|
|
993
|
+
|
|
994
|
+
if (err < 0) {
|
|
995
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
996
|
+
assert(err == 0);
|
|
997
|
+
|
|
998
|
+
throw js_pending_exception;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
req->active = true;
|
|
968
1002
|
}
|
|
969
1003
|
|
|
970
1004
|
static int
|
|
@@ -983,11 +1017,11 @@ rocksdb_native__on_iterator_read(rocksdb_iterator_t *handle, int status) {
|
|
|
983
1017
|
|
|
984
1018
|
assert(status == 0);
|
|
985
1019
|
|
|
986
|
-
|
|
1020
|
+
auto req = reinterpret_cast<rocksdb_native_iterator_t *>(handle->data);
|
|
987
1021
|
|
|
988
1022
|
req->active = false;
|
|
989
1023
|
|
|
990
|
-
|
|
1024
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
991
1025
|
|
|
992
1026
|
size_t len = req->handle.len;
|
|
993
1027
|
|
|
@@ -1005,7 +1039,7 @@ rocksdb_native__on_iterator_read(rocksdb_iterator_t *handle, int status) {
|
|
|
1005
1039
|
err = rocksdb_iterator_close(&req->handle, rocksdb_native__on_iterator_close);
|
|
1006
1040
|
assert(err == 0);
|
|
1007
1041
|
} else {
|
|
1008
|
-
|
|
1042
|
+
auto env = req->env;
|
|
1009
1043
|
|
|
1010
1044
|
js_handle_scope_t *scope;
|
|
1011
1045
|
err = js_open_handle_scope(env, &scope);
|
|
@@ -1015,7 +1049,7 @@ rocksdb_native__on_iterator_read(rocksdb_iterator_t *handle, int status) {
|
|
|
1015
1049
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1016
1050
|
assert(err == 0);
|
|
1017
1051
|
|
|
1018
|
-
|
|
1052
|
+
rocksdb_native_on_iterator_read_t cb;
|
|
1019
1053
|
err = js_get_reference_value(env, req->on_read, cb);
|
|
1020
1054
|
assert(err == 0);
|
|
1021
1055
|
|
|
@@ -1065,10 +1099,16 @@ rocksdb_native_iterator_read(
|
|
|
1065
1099
|
) {
|
|
1066
1100
|
int err;
|
|
1067
1101
|
|
|
1068
|
-
req->active = true;
|
|
1069
|
-
|
|
1070
1102
|
err = rocksdb_iterator_read(&req->handle, req->keys, req->values, capacity, rocksdb_native__on_iterator_read);
|
|
1071
|
-
|
|
1103
|
+
|
|
1104
|
+
if (err < 0) {
|
|
1105
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1106
|
+
assert(err == 0);
|
|
1107
|
+
|
|
1108
|
+
throw js_pending_exception;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
req->active = true;
|
|
1072
1112
|
}
|
|
1073
1113
|
|
|
1074
1114
|
static js_arraybuffer_t
|
|
@@ -1113,11 +1153,11 @@ rocksdb_native__on_read(rocksdb_read_batch_t *handle, int status) {
|
|
|
1113
1153
|
|
|
1114
1154
|
assert(status == 0);
|
|
1115
1155
|
|
|
1116
|
-
|
|
1156
|
+
auto req = reinterpret_cast<rocksdb_native_read_batch_t *>(handle->data);
|
|
1117
1157
|
|
|
1118
|
-
|
|
1158
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
1119
1159
|
|
|
1120
|
-
|
|
1160
|
+
auto env = req->env;
|
|
1121
1161
|
|
|
1122
1162
|
size_t len = req->handle.len;
|
|
1123
1163
|
|
|
@@ -1180,7 +1220,7 @@ rocksdb_native__on_read(rocksdb_read_batch_t *handle, int status) {
|
|
|
1180
1220
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1181
1221
|
assert(err == 0);
|
|
1182
1222
|
|
|
1183
|
-
|
|
1223
|
+
rocksdb_native_on_read_t cb;
|
|
1184
1224
|
err = js_get_reference_value(env, req->on_read, cb);
|
|
1185
1225
|
assert(err == 0);
|
|
1186
1226
|
|
|
@@ -1204,18 +1244,11 @@ rocksdb_native_read(
|
|
|
1204
1244
|
bool async_io,
|
|
1205
1245
|
bool fill_cache,
|
|
1206
1246
|
js_receiver_t ctx,
|
|
1207
|
-
|
|
1247
|
+
rocksdb_native_on_read_t on_read
|
|
1208
1248
|
) {
|
|
1209
1249
|
int err;
|
|
1210
1250
|
|
|
1211
|
-
err = js_create_reference(env, ctx, req->ctx);
|
|
1212
|
-
assert(err == 0);
|
|
1213
|
-
|
|
1214
|
-
err = js_create_reference(env, on_read, req->on_read);
|
|
1215
|
-
assert(err == 0);
|
|
1216
|
-
|
|
1217
1251
|
std::vector<js_object_t> elements;
|
|
1218
|
-
|
|
1219
1252
|
err = js_get_array_elements(env, operations, elements);
|
|
1220
1253
|
assert(err == 0);
|
|
1221
1254
|
|
|
@@ -1268,6 +1301,18 @@ rocksdb_native_read(
|
|
|
1268
1301
|
}
|
|
1269
1302
|
|
|
1270
1303
|
err = rocksdb_read(&db->handle, &req->handle, req->reads, len, &options, rocksdb_native__on_read);
|
|
1304
|
+
|
|
1305
|
+
if (err < 0) {
|
|
1306
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1307
|
+
assert(err == 0);
|
|
1308
|
+
|
|
1309
|
+
throw js_pending_exception;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
err = js_create_reference(env, ctx, req->ctx);
|
|
1313
|
+
assert(err == 0);
|
|
1314
|
+
|
|
1315
|
+
err = js_create_reference(env, on_read, req->on_read);
|
|
1271
1316
|
assert(err == 0);
|
|
1272
1317
|
}
|
|
1273
1318
|
|
|
@@ -1313,11 +1358,11 @@ rocksdb_native__on_write(rocksdb_write_batch_t *handle, int status) {
|
|
|
1313
1358
|
|
|
1314
1359
|
assert(status == 0);
|
|
1315
1360
|
|
|
1316
|
-
|
|
1361
|
+
auto req = reinterpret_cast<rocksdb_native_write_batch_t *>(handle->data);
|
|
1317
1362
|
|
|
1318
|
-
|
|
1363
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
1319
1364
|
|
|
1320
|
-
|
|
1365
|
+
auto env = req->env;
|
|
1321
1366
|
|
|
1322
1367
|
if (db->exiting) {
|
|
1323
1368
|
req->on_write.reset();
|
|
@@ -1338,7 +1383,7 @@ rocksdb_native__on_write(rocksdb_write_batch_t *handle, int status) {
|
|
|
1338
1383
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1339
1384
|
assert(err == 0);
|
|
1340
1385
|
|
|
1341
|
-
|
|
1386
|
+
rocksdb_native_on_write_t cb;
|
|
1342
1387
|
err = js_get_reference_value(env, req->on_write, cb);
|
|
1343
1388
|
assert(err == 0);
|
|
1344
1389
|
|
|
@@ -1359,18 +1404,11 @@ rocksdb_native_write(
|
|
|
1359
1404
|
js_arraybuffer_span_of_t<rocksdb_native_write_batch_t, 1> req,
|
|
1360
1405
|
js_array_t operations,
|
|
1361
1406
|
js_receiver_t ctx,
|
|
1362
|
-
|
|
1407
|
+
rocksdb_native_on_write_t on_write
|
|
1363
1408
|
) {
|
|
1364
1409
|
int err;
|
|
1365
1410
|
|
|
1366
|
-
err = js_create_reference(env, ctx, req->ctx);
|
|
1367
|
-
assert(err == 0);
|
|
1368
|
-
|
|
1369
|
-
err = js_create_reference(env, on_write, req->on_write);
|
|
1370
|
-
assert(err == 0);
|
|
1371
|
-
|
|
1372
1411
|
std::vector<js_object_t> elements;
|
|
1373
|
-
|
|
1374
1412
|
err = js_get_array_elements(env, operations, elements);
|
|
1375
1413
|
assert(err == 0);
|
|
1376
1414
|
|
|
@@ -1450,6 +1488,18 @@ rocksdb_native_write(
|
|
|
1450
1488
|
}
|
|
1451
1489
|
|
|
1452
1490
|
err = rocksdb_write(&db->handle, &req->handle, req->writes, len, NULL, rocksdb_native__on_write);
|
|
1491
|
+
|
|
1492
|
+
if (err < 0) {
|
|
1493
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1494
|
+
assert(err == 0);
|
|
1495
|
+
|
|
1496
|
+
throw js_pending_exception;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
err = js_create_reference(env, ctx, req->ctx);
|
|
1500
|
+
assert(err == 0);
|
|
1501
|
+
|
|
1502
|
+
err = js_create_reference(env, on_write, req->on_write);
|
|
1453
1503
|
assert(err == 0);
|
|
1454
1504
|
}
|
|
1455
1505
|
|
|
@@ -1459,11 +1509,11 @@ rocksdb_native__on_flush(rocksdb_flush_t *handle, int status) {
|
|
|
1459
1509
|
|
|
1460
1510
|
assert(status == 0);
|
|
1461
1511
|
|
|
1462
|
-
|
|
1512
|
+
auto req = reinterpret_cast<rocksdb_native_flush_t *>(handle->data);
|
|
1463
1513
|
|
|
1464
|
-
|
|
1514
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
1465
1515
|
|
|
1466
|
-
|
|
1516
|
+
auto env = req->env;
|
|
1467
1517
|
|
|
1468
1518
|
if (db->exiting) {
|
|
1469
1519
|
req->on_flush.reset();
|
|
@@ -1484,7 +1534,7 @@ rocksdb_native__on_flush(rocksdb_flush_t *handle, int status) {
|
|
|
1484
1534
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1485
1535
|
assert(err == 0);
|
|
1486
1536
|
|
|
1487
|
-
|
|
1537
|
+
rocksdb_native_on_flush_t cb;
|
|
1488
1538
|
err = js_get_reference_value(env, req->on_flush, cb);
|
|
1489
1539
|
assert(err == 0);
|
|
1490
1540
|
|
|
@@ -1504,7 +1554,7 @@ rocksdb_native_flush(
|
|
|
1504
1554
|
js_arraybuffer_span_of_t<rocksdb_native_t, 1> db,
|
|
1505
1555
|
js_arraybuffer_span_of_t<rocksdb_native_column_family_t, 1> column_family,
|
|
1506
1556
|
js_receiver_t ctx,
|
|
1507
|
-
|
|
1557
|
+
rocksdb_native_on_flush_t on_flush
|
|
1508
1558
|
) {
|
|
1509
1559
|
int err;
|
|
1510
1560
|
|
|
@@ -1515,52 +1565,37 @@ rocksdb_native_flush(
|
|
|
1515
1565
|
assert(err == 0);
|
|
1516
1566
|
|
|
1517
1567
|
req->env = env;
|
|
1518
|
-
req->handle.data =
|
|
1519
|
-
|
|
1520
|
-
err = js_create_reference(env, ctx, req->ctx);
|
|
1521
|
-
assert(err == 0);
|
|
1522
|
-
|
|
1523
|
-
err = js_create_reference(env, on_flush, req->on_flush);
|
|
1524
|
-
assert(err == 0);
|
|
1568
|
+
req->handle.data = req;
|
|
1525
1569
|
|
|
1526
1570
|
err = rocksdb_flush(&db->handle, &req->handle, column_family->handle, NULL, rocksdb_native__on_flush);
|
|
1527
|
-
assert(err == 0);
|
|
1528
1571
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
static js_arraybuffer_t
|
|
1533
|
-
rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_t, 1> db) {
|
|
1534
|
-
int err;
|
|
1572
|
+
if (err < 0) {
|
|
1573
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1574
|
+
assert(err == 0);
|
|
1535
1575
|
|
|
1536
|
-
|
|
1576
|
+
throw js_pending_exception;
|
|
1577
|
+
}
|
|
1537
1578
|
|
|
1538
|
-
|
|
1539
|
-
err = js_create_arraybuffer(env, snapshot, handle);
|
|
1579
|
+
err = js_create_reference(env, ctx, req->ctx);
|
|
1540
1580
|
assert(err == 0);
|
|
1541
1581
|
|
|
1542
|
-
err =
|
|
1582
|
+
err = js_create_reference(env, on_flush, req->on_flush);
|
|
1543
1583
|
assert(err == 0);
|
|
1544
1584
|
|
|
1545
1585
|
return handle;
|
|
1546
1586
|
}
|
|
1547
1587
|
|
|
1548
|
-
static void
|
|
1549
|
-
rocksdb_native_snapshot_destroy(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1> snapshot) {
|
|
1550
|
-
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
1588
|
static void
|
|
1554
1589
|
rocksdb_native__on_compact_range(rocksdb_compact_range_t *handle, int status) {
|
|
1555
1590
|
int err;
|
|
1556
1591
|
|
|
1557
1592
|
assert(status == 0);
|
|
1558
1593
|
|
|
1559
|
-
|
|
1594
|
+
auto req = reinterpret_cast<rocksdb_native_compact_range_t *>(handle->data);
|
|
1560
1595
|
|
|
1561
|
-
|
|
1596
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
1562
1597
|
|
|
1563
|
-
|
|
1598
|
+
auto env = req->env;
|
|
1564
1599
|
|
|
1565
1600
|
if (db->exiting) {
|
|
1566
1601
|
req->on_compact_range.reset();
|
|
@@ -1581,7 +1616,7 @@ rocksdb_native__on_compact_range(rocksdb_compact_range_t *handle, int status) {
|
|
|
1581
1616
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1582
1617
|
assert(err == 0);
|
|
1583
1618
|
|
|
1584
|
-
|
|
1619
|
+
rocksdb_native_on_compact_range_t cb;
|
|
1585
1620
|
err = js_get_reference_value(env, req->on_compact_range, cb);
|
|
1586
1621
|
assert(err == 0);
|
|
1587
1622
|
|
|
@@ -1604,10 +1639,18 @@ rocksdb_native_compact_range(
|
|
|
1604
1639
|
js_typedarray_t<> end,
|
|
1605
1640
|
bool exclusive,
|
|
1606
1641
|
js_receiver_t ctx,
|
|
1607
|
-
|
|
1642
|
+
rocksdb_native_on_compact_range_t on_compact_range
|
|
1608
1643
|
) {
|
|
1609
1644
|
int err;
|
|
1610
1645
|
|
|
1646
|
+
rocksdb_slice_t start_slice;
|
|
1647
|
+
err = js_get_typedarray_info(env, start, start_slice.data, start_slice.len);
|
|
1648
|
+
assert(err == 0);
|
|
1649
|
+
|
|
1650
|
+
rocksdb_slice_t end_slice;
|
|
1651
|
+
err = js_get_typedarray_info(env, end, end_slice.data, end_slice.len);
|
|
1652
|
+
assert(err == 0);
|
|
1653
|
+
|
|
1611
1654
|
js_arraybuffer_t handle;
|
|
1612
1655
|
|
|
1613
1656
|
rocksdb_native_compact_range_t *req;
|
|
@@ -1615,28 +1658,26 @@ rocksdb_native_compact_range(
|
|
|
1615
1658
|
assert(err == 0);
|
|
1616
1659
|
|
|
1617
1660
|
req->env = env;
|
|
1618
|
-
req->handle.data =
|
|
1619
|
-
|
|
1620
|
-
err = js_create_reference(env, ctx, req->ctx);
|
|
1621
|
-
assert(err == 0);
|
|
1622
|
-
|
|
1623
|
-
err = js_create_reference(env, on_compact_range, req->on_compact_range);
|
|
1624
|
-
assert(err == 0);
|
|
1661
|
+
req->handle.data = req;
|
|
1625
1662
|
|
|
1626
1663
|
rocksdb_compact_range_options_t options = {
|
|
1627
1664
|
.version = 0,
|
|
1628
1665
|
.exclusive_manual_compaction = exclusive
|
|
1629
1666
|
};
|
|
1630
1667
|
|
|
1631
|
-
|
|
1632
|
-
err = js_get_typedarray_info(env, start, start_slice.data, start_slice.len);
|
|
1633
|
-
assert(err == 0);
|
|
1668
|
+
err = rocksdb_compact_range(&db->handle, &req->handle, column_family->handle, start_slice, end_slice, &options, rocksdb_native__on_compact_range);
|
|
1634
1669
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1670
|
+
if (err < 0) {
|
|
1671
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1672
|
+
assert(err == 0);
|
|
1673
|
+
|
|
1674
|
+
throw js_pending_exception;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
err = js_create_reference(env, ctx, req->ctx);
|
|
1637
1678
|
assert(err == 0);
|
|
1638
1679
|
|
|
1639
|
-
err =
|
|
1680
|
+
err = js_create_reference(env, on_compact_range, req->on_compact_range);
|
|
1640
1681
|
assert(err == 0);
|
|
1641
1682
|
|
|
1642
1683
|
return handle;
|
|
@@ -1648,11 +1689,11 @@ rocksdb_native__on_approximate_size(rocksdb_approximate_size_t *handle, int stat
|
|
|
1648
1689
|
|
|
1649
1690
|
assert(status == 0);
|
|
1650
1691
|
|
|
1651
|
-
|
|
1692
|
+
auto req = reinterpret_cast<rocksdb_native_approximate_size_t *>(handle->data);
|
|
1652
1693
|
|
|
1653
|
-
|
|
1694
|
+
auto db = reinterpret_cast<rocksdb_native_t *>(req->handle.req.db);
|
|
1654
1695
|
|
|
1655
|
-
|
|
1696
|
+
auto env = req->env;
|
|
1656
1697
|
|
|
1657
1698
|
if (db->exiting) {
|
|
1658
1699
|
req->on_approximate_size.reset();
|
|
@@ -1673,7 +1714,7 @@ rocksdb_native__on_approximate_size(rocksdb_approximate_size_t *handle, int stat
|
|
|
1673
1714
|
err = js_get_reference_value(env, req->ctx, ctx);
|
|
1674
1715
|
assert(err == 0);
|
|
1675
1716
|
|
|
1676
|
-
|
|
1717
|
+
rocksdb_native_on_approximate_size_t cb;
|
|
1677
1718
|
err = js_get_reference_value(env, req->on_approximate_size, cb);
|
|
1678
1719
|
assert(err == 0);
|
|
1679
1720
|
|
|
@@ -1698,10 +1739,18 @@ rocksdb_native_approximate_size(
|
|
|
1698
1739
|
bool include_files,
|
|
1699
1740
|
double error_margin,
|
|
1700
1741
|
js_receiver_t ctx,
|
|
1701
|
-
|
|
1742
|
+
rocksdb_native_on_approximate_size_t on_approximate_size
|
|
1702
1743
|
) {
|
|
1703
1744
|
int err;
|
|
1704
1745
|
|
|
1746
|
+
rocksdb_slice_t start_slice;
|
|
1747
|
+
err = js_get_typedarray_info(env, start, start_slice.data, start_slice.len);
|
|
1748
|
+
assert(err == 0);
|
|
1749
|
+
|
|
1750
|
+
rocksdb_slice_t end_slice;
|
|
1751
|
+
err = js_get_typedarray_info(env, end, end_slice.data, end_slice.len);
|
|
1752
|
+
assert(err == 0);
|
|
1753
|
+
|
|
1705
1754
|
js_arraybuffer_t handle;
|
|
1706
1755
|
|
|
1707
1756
|
rocksdb_native_approximate_size_t *req;
|
|
@@ -1709,13 +1758,7 @@ rocksdb_native_approximate_size(
|
|
|
1709
1758
|
assert(err == 0);
|
|
1710
1759
|
|
|
1711
1760
|
req->env = env;
|
|
1712
|
-
req->handle.data =
|
|
1713
|
-
|
|
1714
|
-
err = js_create_reference(env, ctx, req->ctx);
|
|
1715
|
-
assert(err == 0);
|
|
1716
|
-
|
|
1717
|
-
err = js_create_reference(env, on_approximate_size, req->on_approximate_size);
|
|
1718
|
-
assert(err == 0);
|
|
1761
|
+
req->handle.data = req;
|
|
1719
1762
|
|
|
1720
1763
|
rocksdb_approximate_size_options_t options = {
|
|
1721
1764
|
.version = 0,
|
|
@@ -1724,20 +1767,51 @@ rocksdb_native_approximate_size(
|
|
|
1724
1767
|
.files_size_error_margin = error_margin,
|
|
1725
1768
|
};
|
|
1726
1769
|
|
|
1727
|
-
|
|
1728
|
-
|
|
1770
|
+
err = rocksdb_approximate_size(&db->handle, &req->handle, column_family->handle, start_slice, end_slice, &options, rocksdb_native__on_approximate_size);
|
|
1771
|
+
|
|
1772
|
+
if (err < 0) {
|
|
1773
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1774
|
+
assert(err == 0);
|
|
1775
|
+
|
|
1776
|
+
throw js_pending_exception;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
err = js_create_reference(env, ctx, req->ctx);
|
|
1729
1780
|
assert(err == 0);
|
|
1730
1781
|
|
|
1731
|
-
|
|
1732
|
-
err = js_get_typedarray_info(env, end, end_slice.data, end_slice.len);
|
|
1782
|
+
err = js_create_reference(env, on_approximate_size, req->on_approximate_size);
|
|
1733
1783
|
assert(err == 0);
|
|
1734
1784
|
|
|
1735
|
-
|
|
1785
|
+
return handle;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
static js_arraybuffer_t
|
|
1789
|
+
rocksdb_native_snapshot_create(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_t, 1> db) {
|
|
1790
|
+
int err;
|
|
1791
|
+
|
|
1792
|
+
js_arraybuffer_t handle;
|
|
1793
|
+
|
|
1794
|
+
rocksdb_native_snapshot_t *snapshot;
|
|
1795
|
+
err = js_create_arraybuffer(env, snapshot, handle);
|
|
1736
1796
|
assert(err == 0);
|
|
1737
1797
|
|
|
1798
|
+
err = rocksdb_snapshot_create(&db->handle, &snapshot->handle);
|
|
1799
|
+
|
|
1800
|
+
if (err < 0) {
|
|
1801
|
+
err = js_throw_error(env, uv_err_name(err), uv_strerror(err));
|
|
1802
|
+
assert(err == 0);
|
|
1803
|
+
|
|
1804
|
+
throw js_pending_exception;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1738
1807
|
return handle;
|
|
1739
1808
|
}
|
|
1740
1809
|
|
|
1810
|
+
static void
|
|
1811
|
+
rocksdb_native_snapshot_destroy(js_env_t *env, js_arraybuffer_span_of_t<rocksdb_native_snapshot_t, 1> snapshot) {
|
|
1812
|
+
rocksdb_snapshot_destroy(&snapshot->handle);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1741
1815
|
static js_value_t *
|
|
1742
1816
|
rocksdb_native_exports(js_env_t *env, js_value_t *exports) {
|
|
1743
1817
|
int err;
|
|
@@ -1770,12 +1844,11 @@ rocksdb_native_exports(js_env_t *env, js_value_t *exports) {
|
|
|
1770
1844
|
V("iteratorRead", rocksdb_native_iterator_read)
|
|
1771
1845
|
|
|
1772
1846
|
V("flush", rocksdb_native_flush)
|
|
1847
|
+
V("compactRange", rocksdb_native_compact_range)
|
|
1848
|
+
V("approximateSize", rocksdb_native_approximate_size)
|
|
1773
1849
|
|
|
1774
1850
|
V("snapshotCreate", rocksdb_native_snapshot_create)
|
|
1775
1851
|
V("snapshotDestroy", rocksdb_native_snapshot_destroy)
|
|
1776
|
-
|
|
1777
|
-
V("compactRange", rocksdb_native_compact_range)
|
|
1778
|
-
V("approximateSize", rocksdb_native_approximate_size)
|
|
1779
1852
|
#undef V
|
|
1780
1853
|
|
|
1781
1854
|
#define V(name, n) \
|
package/lib/state.js
CHANGED
|
@@ -320,7 +320,10 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
320
320
|
|
|
321
321
|
const { exclusive = false } = opts
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
start = this._encodeKey(start)
|
|
324
|
+
end = this._encodeKey(end)
|
|
325
|
+
|
|
326
|
+
const req = { resolve: null, reject: null, handle: null, start, end }
|
|
324
327
|
|
|
325
328
|
const promise = new Promise((resolve, reject) => {
|
|
326
329
|
req.resolve = resolve
|
|
@@ -331,8 +334,8 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
331
334
|
req.handle = binding.compactRange(
|
|
332
335
|
this._handle,
|
|
333
336
|
db._columnFamily._handle,
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
start,
|
|
338
|
+
end,
|
|
336
339
|
exclusive,
|
|
337
340
|
req,
|
|
338
341
|
oncompactrange
|
|
@@ -356,7 +359,10 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
356
359
|
|
|
357
360
|
const { includeMemtables = false, includeFiles = true, filesSizeErrorMargin = -1 } = opts
|
|
358
361
|
|
|
359
|
-
|
|
362
|
+
start = this._encodeKey(start)
|
|
363
|
+
end = this._encodeKey(end)
|
|
364
|
+
|
|
365
|
+
const req = { resolve: null, reject: null, handle: null, start, end }
|
|
360
366
|
|
|
361
367
|
const promise = new Promise((resolve, reject) => {
|
|
362
368
|
req.resolve = resolve
|
|
@@ -367,8 +373,8 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
367
373
|
req.handle = binding.approximateSize(
|
|
368
374
|
this._handle,
|
|
369
375
|
db._columnFamily._handle,
|
|
370
|
-
|
|
371
|
-
|
|
376
|
+
start,
|
|
377
|
+
end,
|
|
372
378
|
includeMemtables,
|
|
373
379
|
includeFiles,
|
|
374
380
|
filesSizeErrorMargin,
|
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
|