@nxtedition/rocksdb 11.0.4 → 11.0.5

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 CHANGED
@@ -307,12 +307,15 @@ struct BaseIterator : public Closable {
307
307
  }
308
308
 
309
309
  rocksdb::ReadOptions readOptions;
310
+
310
311
  if (upper_bound_) {
311
312
  readOptions.iterate_upper_bound = &*upper_bound_;
312
313
  }
314
+
313
315
  if (lower_bound_) {
314
316
  readOptions.iterate_lower_bound = &*lower_bound_;
315
317
  }
318
+
316
319
  readOptions.fill_cache = fillCache;
317
320
  readOptions.async_io = true;
318
321
  readOptions.adaptive_readahead = true;
@@ -329,9 +332,15 @@ struct BaseIterator : public Closable {
329
332
  database_->Attach(this);
330
333
  }
331
334
 
332
- virtual ~BaseIterator() { assert(!iterator_); }
335
+ virtual ~BaseIterator() {
336
+ if (iterator_) {
337
+ database_->Detach(this);
338
+ }
339
+ }
333
340
 
334
341
  virtual void Seek(const rocksdb::Slice& target) {
342
+ assert(iterator_);
343
+
335
344
  if ((upper_bound_ && target.compare(*upper_bound_) >= 0) || (lower_bound_ && target.compare(*lower_bound_) < 0)) {
336
345
  // TODO (fix): Why is this required? Seek should handle it?
337
346
  // https://github.com/facebook/rocksdb/issues/9904
@@ -347,8 +356,10 @@ struct BaseIterator : public Closable {
347
356
  }
348
357
 
349
358
  virtual rocksdb::Status Close() override {
350
- iterator_.reset();
351
- database_->Detach(this);
359
+ if (iterator_) {
360
+ iterator_.reset();
361
+ database_->Detach(this);
362
+ }
352
363
  return rocksdb::Status::OK();
353
364
  }
354
365
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "11.0.4",
3
+ "version": "11.0.5",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",