@nxtedition/rocksdb 10.0.10 → 10.0.12

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
@@ -323,30 +323,14 @@ struct BaseIterator : public Closable {
323
323
 
324
324
  virtual ~BaseIterator() { assert(!iterator_); }
325
325
 
326
- bool DidSeek() const { return iterator_ != nullptr && !target_; }
326
+ bool DidSeek() const { return iterator_ != nullptr; }
327
327
 
328
328
  void SeekToRange() {
329
329
  if (!iterator_) {
330
330
  Init();
331
331
  }
332
332
 
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_) {
333
+ if (reverse_) {
350
334
  iterator_->SeekToLast();
351
335
  } else {
352
336
  iterator_->SeekToFirst();
@@ -354,8 +338,22 @@ struct BaseIterator : public Closable {
354
338
  }
355
339
 
356
340
  void Seek(const rocksdb::Slice& target) {
357
- target_ = rocksdb::PinnableSlice();
358
- target_->PinSelf(target);
341
+ if (!iterator_) {
342
+ Init();
343
+ }
344
+
345
+ if ((upper_bound_ && target.compare(*upper_bound_) >= 0) || (lower_bound_ && target.compare(*lower_bound_) < 0)) {
346
+ // TODO (fix): Why is this required? Seek should handle it?
347
+ // https://github.com/facebook/rocksdb/issues/9904
348
+ iterator_->SeekToLast();
349
+ if (iterator_->Valid()) {
350
+ iterator_->Next();
351
+ }
352
+ } else if (reverse_) {
353
+ iterator_->SeekForPrev(target);
354
+ } else {
355
+ iterator_->Seek(target);
356
+ }
359
357
  }
360
358
 
361
359
  rocksdb::Status Close() override {
@@ -423,7 +421,6 @@ struct BaseIterator : public Closable {
423
421
  int count_ = 0;
424
422
  std::optional<rocksdb::PinnableSlice> lower_bound_;
425
423
  std::optional<rocksdb::PinnableSlice> upper_bound_;
426
- std::optional<rocksdb::PinnableSlice> target_;
427
424
  std::unique_ptr<rocksdb::Iterator> iterator_;
428
425
  const bool reverse_;
429
426
  const int limit_;
@@ -1278,7 +1275,7 @@ NAPI_METHOD(iterator_seek) {
1278
1275
  NAPI_STATUS_THROWS(GetValue(env, argv[1], target));
1279
1276
 
1280
1277
  iterator->first_ = true;
1281
- iterator->Seek(target);
1278
+ iterator->Seek(target); // TODO: Does seek causing blocking IO?
1282
1279
 
1283
1280
  return 0;
1284
1281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "10.0.10",
3
+ "version": "10.0.12",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",