@nxtedition/rocksdb 10.0.8 → 10.0.10

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
@@ -330,10 +330,11 @@ struct BaseIterator : public Closable {
330
330
  Init();
331
331
  }
332
332
 
333
- if (target_) {
334
- auto target = rocksdb::Slice(*target_);
333
+ const auto target = std::move(target_);
335
334
 
336
- if ((upper_bound_ && target.compare(*upper_bound_) >= 0) || (lower_bound_ && target.compare(*lower_bound_) < 0)) {
335
+ if (target) {
336
+ if ((upper_bound_ && target->compare(*upper_bound_) >= 0) ||
337
+ (lower_bound_ && target->compare(*lower_bound_) < 0)) {
337
338
  // TODO (fix): Why is this required? Seek should handle it?
338
339
  // https://github.com/facebook/rocksdb/issues/9904
339
340
  iterator_->SeekToLast();
@@ -341,12 +342,10 @@ struct BaseIterator : public Closable {
341
342
  iterator_->Next();
342
343
  }
343
344
  } else if (reverse_) {
344
- iterator_->SeekForPrev(target);
345
+ iterator_->SeekForPrev(*target);
345
346
  } else {
346
- iterator_->Seek(target);
347
+ iterator_->Seek(*target);
347
348
  }
348
-
349
- target_ = std::nullopt;
350
349
  } else if (reverse_) {
351
350
  iterator_->SeekToLast();
352
351
  } else {
@@ -354,7 +353,10 @@ struct BaseIterator : public Closable {
354
353
  }
355
354
  }
356
355
 
357
- void Seek(const rocksdb::Slice& target) { target_ = target.ToString(); }
356
+ void Seek(const rocksdb::Slice& target) {
357
+ target_ = rocksdb::PinnableSlice();
358
+ target_->PinSelf(target);
359
+ }
358
360
 
359
361
  rocksdb::Status Close() override {
360
362
  snapshot_.reset();
@@ -421,8 +423,8 @@ struct BaseIterator : public Closable {
421
423
  int count_ = 0;
422
424
  std::optional<rocksdb::PinnableSlice> lower_bound_;
423
425
  std::optional<rocksdb::PinnableSlice> upper_bound_;
426
+ std::optional<rocksdb::PinnableSlice> target_;
424
427
  std::unique_ptr<rocksdb::Iterator> iterator_;
425
- std::optional<std::string> target_;
426
428
  const bool reverse_;
427
429
  const int limit_;
428
430
  const bool fillCache_;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "10.0.8",
3
+ "version": "10.0.10",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",