rocksdb-native 3.9.3 → 3.10.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/lib/batch.js CHANGED
@@ -214,18 +214,14 @@ exports.ReadBatch = class RocksDBReadBatch extends RocksDBBatch {
214
214
  let applied = true
215
215
 
216
216
  for (let i = 0, n = this._promises.length; i < n; i++) {
217
- const promise = this._promises[i]
218
- if (promise === null) continue
219
-
220
217
  const err = errs[i]
218
+ if (err) applied = false
221
219
 
222
- if (err) {
223
- applied = false
220
+ const promise = this._promises[i]
221
+ if (promise === null) continue
224
222
 
225
- promise.reject(new Error(err))
226
- } else {
227
- promise.resolve(values[i] ? this._decodeValue(Buffer.from(values[i])) : null)
228
- }
223
+ if (err) promise.reject(new Error(err))
224
+ else promise.resolve(values[i] ? this._decodeValue(Buffer.from(values[i])) : null)
229
225
  }
230
226
 
231
227
  this._onfinished(applied ? null : new Error('Batch was not applied'))
@@ -274,19 +270,14 @@ exports.WriteBatch = class RocksDBWriteBatch extends RocksDBBatch {
274
270
  }
275
271
 
276
272
  _onwrite(err) {
277
- let applied = true
273
+ const applied = !err
278
274
 
279
275
  for (let i = 0, n = this._promises.length; i < n; i++) {
280
276
  const promise = this._promises[i]
281
277
  if (promise === null) continue
282
278
 
283
- if (err) {
284
- applied = false
285
-
286
- promise.reject(new Error(err))
287
- } else {
288
- promise.resolve()
289
- }
279
+ if (err) promise.reject(new Error(err))
280
+ else promise.resolve()
290
281
  }
291
282
 
292
283
  this._onfinished(applied ? null : new Error('Batch was not applied'))
package/lib/state.js CHANGED
@@ -27,7 +27,8 @@ module.exports = class RocksDBState extends ReadyResource {
27
27
  avoidUnnecessaryBlockingIO = false,
28
28
  skipStatsUpdateOnOpen = false,
29
29
  useDirectIOForFlushAndCompaction = false,
30
- maxFileOpeningThreads = 16
30
+ maxFileOpeningThreads = 16,
31
+ preopen = null
31
32
  } = opts
32
33
 
33
34
  this.path = path
@@ -44,6 +45,7 @@ module.exports = class RocksDBState extends ReadyResource {
44
45
  this._updating = false
45
46
  this._updatingSignal = new SignalPromise()
46
47
  this._columnsFlushed = false
48
+ this._preopen = preopen
47
49
  this._readBatches = []
48
50
  this._writeBatches = []
49
51
 
@@ -136,6 +138,8 @@ module.exports = class RocksDBState extends ReadyResource {
136
138
  async _open() {
137
139
  await Promise.resolve() // allow column families to populate if ondemand
138
140
 
141
+ if (this._preopen) await this._preopen
142
+
139
143
  const req = { resolve: null, reject: null, handle: null }
140
144
 
141
145
  const promise = new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rocksdb-native",
3
- "version": "3.9.3",
3
+ "version": "3.10.0",
4
4
  "description": "librocksdb bindings for JavaScript",
5
5
  "exports": {
6
6
  ".": "./index.js",