rocksdb-native 3.4.0 → 3.5.0
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.c +107 -0
- package/index.js +6 -0
- package/lib/batch.js +2 -2
- package/lib/column-family.js +1 -0
- package/lib/iterator.js +1 -1
- package/lib/snapshot.js +1 -1
- package/lib/state.js +34 -7
- 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
package/binding.c
CHANGED
|
@@ -107,6 +107,16 @@ typedef struct {
|
|
|
107
107
|
js_ref_t *on_status;
|
|
108
108
|
} rocksdb_native_write_batch_t;
|
|
109
109
|
|
|
110
|
+
typedef struct {
|
|
111
|
+
rocksdb_flush_t handle;
|
|
112
|
+
|
|
113
|
+
js_env_t *env;
|
|
114
|
+
js_ref_t *ctx;
|
|
115
|
+
js_ref_t *on_flush;
|
|
116
|
+
|
|
117
|
+
js_ref_t *column_family;
|
|
118
|
+
} rocksdb_native_flush_t;
|
|
119
|
+
|
|
110
120
|
typedef struct {
|
|
111
121
|
rocksdb_snapshot_t handle;
|
|
112
122
|
} rocksdb_native_snapshot_t;
|
|
@@ -1664,6 +1674,101 @@ rocksdb_native_write(js_env_t *env, js_callback_info_t *info) {
|
|
|
1664
1674
|
return NULL;
|
|
1665
1675
|
}
|
|
1666
1676
|
|
|
1677
|
+
static void
|
|
1678
|
+
rocksdb_native__on_flush(rocksdb_flush_t *handle, int status) {
|
|
1679
|
+
int err;
|
|
1680
|
+
|
|
1681
|
+
assert(status == 0);
|
|
1682
|
+
|
|
1683
|
+
rocksdb_native_flush_t *req = (rocksdb_native_flush_t *) handle->data;
|
|
1684
|
+
|
|
1685
|
+
rocksdb_native_t *db = (rocksdb_native_t *) req->handle.req.db;
|
|
1686
|
+
|
|
1687
|
+
js_env_t *env = req->env;
|
|
1688
|
+
|
|
1689
|
+
if (db->exiting) {
|
|
1690
|
+
err = js_delete_reference(env, req->on_flush);
|
|
1691
|
+
assert(err == 0);
|
|
1692
|
+
|
|
1693
|
+
err = js_delete_reference(env, req->ctx);
|
|
1694
|
+
assert(err == 0);
|
|
1695
|
+
} else {
|
|
1696
|
+
js_handle_scope_t *scope;
|
|
1697
|
+
err = js_open_handle_scope(env, &scope);
|
|
1698
|
+
assert(err == 0);
|
|
1699
|
+
|
|
1700
|
+
js_value_t *error;
|
|
1701
|
+
|
|
1702
|
+
if (req->handle.error) {
|
|
1703
|
+
err = js_create_string_utf8(env, (utf8_t *) req->handle.error, -1, &error);
|
|
1704
|
+
assert(err == 0);
|
|
1705
|
+
} else {
|
|
1706
|
+
err = js_get_null(env, &error);
|
|
1707
|
+
assert(err == 0);
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
js_value_t *ctx;
|
|
1711
|
+
err = js_get_reference_value(env, req->ctx, &ctx);
|
|
1712
|
+
assert(err == 0);
|
|
1713
|
+
|
|
1714
|
+
js_value_t *cb;
|
|
1715
|
+
err = js_get_reference_value(env, req->on_flush, &cb);
|
|
1716
|
+
assert(err == 0);
|
|
1717
|
+
|
|
1718
|
+
err = js_delete_reference(env, req->on_flush);
|
|
1719
|
+
assert(err == 0);
|
|
1720
|
+
|
|
1721
|
+
err = js_delete_reference(env, req->ctx);
|
|
1722
|
+
assert(err == 0);
|
|
1723
|
+
|
|
1724
|
+
js_call_function_with_checkpoint(env, ctx, cb, 1, (js_value_t *[]) {error}, NULL);
|
|
1725
|
+
|
|
1726
|
+
err = js_close_handle_scope(env, scope);
|
|
1727
|
+
assert(err == 0);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
static js_value_t *
|
|
1732
|
+
rocksdb_native_flush(js_env_t *env, js_callback_info_t *info) {
|
|
1733
|
+
int err;
|
|
1734
|
+
|
|
1735
|
+
size_t argc = 4;
|
|
1736
|
+
js_value_t *argv[4];
|
|
1737
|
+
|
|
1738
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
1739
|
+
assert(err == 0);
|
|
1740
|
+
|
|
1741
|
+
assert(argc == 4);
|
|
1742
|
+
|
|
1743
|
+
rocksdb_native_t *db;
|
|
1744
|
+
err = js_get_arraybuffer_info(env, argv[0], (void **) &db, NULL);
|
|
1745
|
+
assert(err == 0);
|
|
1746
|
+
|
|
1747
|
+
rocksdb_native_column_family_t *column_family;
|
|
1748
|
+
err = js_get_arraybuffer_info(env, argv[1], (void **) &column_family, NULL);
|
|
1749
|
+
assert(err == 0);
|
|
1750
|
+
|
|
1751
|
+
js_value_t *handle;
|
|
1752
|
+
|
|
1753
|
+
rocksdb_native_flush_t *req;
|
|
1754
|
+
err = js_create_arraybuffer(env, sizeof(rocksdb_native_flush_t), (void **) &req, &handle);
|
|
1755
|
+
assert(err == 0);
|
|
1756
|
+
|
|
1757
|
+
req->env = env;
|
|
1758
|
+
req->handle.data = (void *) req;
|
|
1759
|
+
|
|
1760
|
+
err = js_create_reference(env, argv[2], 1, &req->ctx);
|
|
1761
|
+
assert(err == 0);
|
|
1762
|
+
|
|
1763
|
+
err = js_create_reference(env, argv[3], 1, &req->on_flush);
|
|
1764
|
+
assert(err == 0);
|
|
1765
|
+
|
|
1766
|
+
err = rocksdb_flush(&db->handle, &req->handle, column_family->handle, NULL, rocksdb_native__on_flush);
|
|
1767
|
+
assert(err == 0);
|
|
1768
|
+
|
|
1769
|
+
return NULL;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1667
1772
|
static js_value_t *
|
|
1668
1773
|
rocksdb_native_snapshot_create(js_env_t *env, js_callback_info_t *info) {
|
|
1669
1774
|
int err;
|
|
@@ -1749,6 +1854,8 @@ rocksdb_native_exports(js_env_t *env, js_value_t *exports) {
|
|
|
1749
1854
|
V("writeBuffer", rocksdb_native_write_buffer)
|
|
1750
1855
|
V("write", rocksdb_native_write)
|
|
1751
1856
|
|
|
1857
|
+
V("flush", rocksdb_native_flush)
|
|
1858
|
+
|
|
1752
1859
|
V("snapshotCreate", rocksdb_native_snapshot_create)
|
|
1753
1860
|
V("snapshotDestroy", rocksdb_native_snapshot_destroy)
|
|
1754
1861
|
#undef V
|
package/index.js
CHANGED
|
@@ -134,6 +134,12 @@ class RocksDB {
|
|
|
134
134
|
return this._state.createWriteBatch(this, opts)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
flush(opts) {
|
|
138
|
+
maybeClosed(this)
|
|
139
|
+
|
|
140
|
+
return this._state.flush(this, opts)
|
|
141
|
+
}
|
|
142
|
+
|
|
137
143
|
async get(key, opts) {
|
|
138
144
|
const batch = this.read({ ...opts, capacity: 1, autoDestroy: true })
|
|
139
145
|
const value = batch.get(key)
|
package/lib/batch.js
CHANGED
|
@@ -175,7 +175,7 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
|
|
|
175
175
|
await super._flush()
|
|
176
176
|
|
|
177
177
|
binding.read(
|
|
178
|
-
this._db._state.
|
|
178
|
+
this._db._state._handle,
|
|
179
179
|
this._handle,
|
|
180
180
|
this._operations,
|
|
181
181
|
this._db._snapshot ? this._db._snapshot._handle : null,
|
|
@@ -242,7 +242,7 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
|
|
|
242
242
|
await super._flush()
|
|
243
243
|
|
|
244
244
|
binding.write(
|
|
245
|
-
this._db._state.
|
|
245
|
+
this._db._state._handle,
|
|
246
246
|
this._handle,
|
|
247
247
|
this._operations,
|
|
248
248
|
this,
|
package/lib/column-family.js
CHANGED
package/lib/iterator.js
CHANGED
package/lib/snapshot.js
CHANGED
package/lib/state.js
CHANGED
|
@@ -36,13 +36,15 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
36
36
|
this._readBatches = []
|
|
37
37
|
this._writeBatches = []
|
|
38
38
|
|
|
39
|
-
for (const
|
|
39
|
+
for (const columnFamily of columnFamilies) {
|
|
40
40
|
this.columnFamilies.push(
|
|
41
|
-
typeof
|
|
41
|
+
typeof columnFamily === 'string'
|
|
42
|
+
? new ColumnFamily(columnFamily, opts)
|
|
43
|
+
: columnFamily
|
|
42
44
|
)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
this.
|
|
47
|
+
this._handle = binding.init(
|
|
46
48
|
readOnly,
|
|
47
49
|
createIfMissing,
|
|
48
50
|
createMissingColumnFamilies,
|
|
@@ -130,7 +132,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
130
132
|
this._columnsFlushed = true
|
|
131
133
|
|
|
132
134
|
req.handle = binding.open(
|
|
133
|
-
this.
|
|
135
|
+
this._handle,
|
|
134
136
|
this,
|
|
135
137
|
this.path,
|
|
136
138
|
this.columnFamilies.map((c) => c._handle),
|
|
@@ -166,7 +168,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
166
168
|
req.reject = reject
|
|
167
169
|
})
|
|
168
170
|
|
|
169
|
-
req.handle = binding.close(this.
|
|
171
|
+
req.handle = binding.close(this._handle, req, onclose)
|
|
170
172
|
|
|
171
173
|
await promise
|
|
172
174
|
|
|
@@ -176,6 +178,31 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
async flush(db, opts) {
|
|
182
|
+
if (this.opened === false) await this.ready()
|
|
183
|
+
|
|
184
|
+
const req = { resolve: null, reject: null, handle: null }
|
|
185
|
+
|
|
186
|
+
const promise = new Promise((resolve, reject) => {
|
|
187
|
+
req.resolve = resolve
|
|
188
|
+
req.reject = reject
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
req.handle = binding.flush(
|
|
192
|
+
this._handle,
|
|
193
|
+
db._columnFamily._handle,
|
|
194
|
+
req,
|
|
195
|
+
onflush
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
await promise
|
|
199
|
+
|
|
200
|
+
function onflush(err) {
|
|
201
|
+
if (err) req.reject(new Error(err))
|
|
202
|
+
else req.resolve()
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
179
206
|
async suspend() {
|
|
180
207
|
if (this._suspending === null) this._suspending = this._suspend()
|
|
181
208
|
return this._suspending
|
|
@@ -192,7 +219,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
192
219
|
req.reject = reject
|
|
193
220
|
})
|
|
194
221
|
|
|
195
|
-
req.handle = binding.suspend(this.
|
|
222
|
+
req.handle = binding.suspend(this._handle, req, onsuspend)
|
|
196
223
|
|
|
197
224
|
try {
|
|
198
225
|
await promise
|
|
@@ -224,7 +251,7 @@ module.exports = class RocksDBState extends ReadyResource {
|
|
|
224
251
|
req.reject = reject
|
|
225
252
|
})
|
|
226
253
|
|
|
227
|
-
req.handle = binding.resume(this.
|
|
254
|
+
req.handle = binding.resume(this._handle, req, onresume)
|
|
228
255
|
|
|
229
256
|
try {
|
|
230
257
|
await promise
|
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
|