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