rocksdb-native 2.0.0 → 2.2.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/binding.c +7 -7
- package/index.js +33 -0
- package/lib/batch.js +0 -8
- package/package.json +1 -1
- 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/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-x64/rocksdb-native.bare +0 -0
- package/prebuilds/win32-x64/rocksdb-native.node +0 -0
package/binding.c
CHANGED
|
@@ -146,7 +146,7 @@ rocksdb_native__on_open (rocksdb_open_t *handle, int status) {
|
|
|
146
146
|
assert(err == 0);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
js_call_function_with_checkpoint(env, ctx, cb, 1, (js_value_t *[]){error}, NULL);
|
|
150
150
|
|
|
151
151
|
err = js_close_handle_scope(env, scope);
|
|
152
152
|
assert(err == 0);
|
|
@@ -241,7 +241,7 @@ rocksdb_native__on_close (rocksdb_close_t *handle, int status) {
|
|
|
241
241
|
err = js_get_reference_value(env, req->on_close, &cb);
|
|
242
242
|
assert(err == 0);
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
js_call_function_with_checkpoint(env, ctx, cb, 0, NULL, NULL);
|
|
245
245
|
|
|
246
246
|
err = js_close_handle_scope(env, scope);
|
|
247
247
|
assert(err == 0);
|
|
@@ -395,7 +395,7 @@ rocksdb_native__on_iterator_open (rocksdb_iterator_t *handle, int status) {
|
|
|
395
395
|
assert(err == 0);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
js_call_function_with_checkpoint(env, ctx, cb, 1, (js_value_t *[]){error}, NULL);
|
|
399
399
|
|
|
400
400
|
err = js_close_handle_scope(env, scope);
|
|
401
401
|
assert(err == 0);
|
|
@@ -477,7 +477,7 @@ rocksdb_native__on_iterator_close (rocksdb_iterator_t *handle, int status) {
|
|
|
477
477
|
assert(err == 0);
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
-
|
|
480
|
+
js_call_function_with_checkpoint(env, ctx, cb, 1, (js_value_t *[]){error}, NULL);
|
|
481
481
|
|
|
482
482
|
err = js_close_handle_scope(env, scope);
|
|
483
483
|
assert(err == 0);
|
|
@@ -567,7 +567,7 @@ rocksdb_native__on_iterator_read (rocksdb_iterator_t *handle, int status) {
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
js_call_function_with_checkpoint(env, ctx, cb, 3, (js_value_t *[]){error, keys, values}, NULL);
|
|
571
571
|
|
|
572
572
|
err = js_close_handle_scope(env, scope);
|
|
573
573
|
assert(err == 0);
|
|
@@ -719,7 +719,7 @@ rocksdb_native__on_read (rocksdb_read_batch_t *handle, int status) {
|
|
|
719
719
|
err = js_get_reference_value(env, batch->on_status, &cb);
|
|
720
720
|
assert(err == 0);
|
|
721
721
|
|
|
722
|
-
|
|
722
|
+
js_call_function_with_checkpoint(env, ctx, cb, 2, (js_value_t *[]){errors, values}, NULL);
|
|
723
723
|
|
|
724
724
|
err = js_close_handle_scope(env, scope);
|
|
725
725
|
assert(err == 0);
|
|
@@ -885,7 +885,7 @@ rocksdb_native__on_write (rocksdb_write_batch_t *handle, int status) {
|
|
|
885
885
|
err = js_get_reference_value(env, batch->on_status, &cb);
|
|
886
886
|
assert(err == 0);
|
|
887
887
|
|
|
888
|
-
|
|
888
|
+
js_call_function_with_checkpoint(env, ctx, cb, 1, (js_value_t *[]){error}, NULL);
|
|
889
889
|
|
|
890
890
|
err = js_close_handle_scope(env, scope);
|
|
891
891
|
assert(err == 0);
|
package/index.js
CHANGED
|
@@ -105,6 +105,14 @@ const RocksDB = module.exports = class RocksDB extends ReadyResource {
|
|
|
105
105
|
return new Iterator(this, opts)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
async peek (opts) {
|
|
109
|
+
for await (const value of this.iterator({ ...opts, limit: 1 })) { // eslint-disable-line no-unreachable-loop
|
|
110
|
+
return value
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
|
|
108
116
|
read (opts) {
|
|
109
117
|
return new ReadBatch(this, opts)
|
|
110
118
|
}
|
|
@@ -113,6 +121,31 @@ const RocksDB = module.exports = class RocksDB extends ReadyResource {
|
|
|
113
121
|
return new WriteBatch(this, opts)
|
|
114
122
|
}
|
|
115
123
|
|
|
124
|
+
async get (key, opts) {
|
|
125
|
+
const batch = this.read(opts)
|
|
126
|
+
const value = batch.get(key)
|
|
127
|
+
await batch.flush()
|
|
128
|
+
return value
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async put (key, value, opts) {
|
|
132
|
+
const batch = this.write(opts)
|
|
133
|
+
batch.put(key, value)
|
|
134
|
+
await batch.flush()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async delete (key, opts) {
|
|
138
|
+
const batch = this.write(opts)
|
|
139
|
+
batch.delete(key)
|
|
140
|
+
await batch.flush()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async deleteRange (start, end, opts) {
|
|
144
|
+
const batch = this.write(opts)
|
|
145
|
+
batch.deleteRange(start, end)
|
|
146
|
+
await batch.flush()
|
|
147
|
+
}
|
|
148
|
+
|
|
116
149
|
static _instances = new Set()
|
|
117
150
|
}
|
|
118
151
|
|
package/lib/batch.js
CHANGED
|
@@ -148,14 +148,6 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
|
|
|
148
148
|
|
|
149
149
|
return promise
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
tryPut (key, value) {
|
|
153
|
-
if (this._request) throw new Error('Request already in progress')
|
|
154
|
-
|
|
155
|
-
this._operations.push(new RocksDBPut(this._encodeKey(key), this._encodeValue(value)))
|
|
156
|
-
this._promises.push(null)
|
|
157
|
-
this._resize()
|
|
158
|
-
}
|
|
159
151
|
}
|
|
160
152
|
|
|
161
153
|
exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|