@nxtedition/rocksdb 10.0.6 → 10.0.9

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,7 +323,7 @@ struct BaseIterator : public Closable {
323
323
 
324
324
  virtual ~BaseIterator() { assert(!iterator_); }
325
325
 
326
- bool DidSeek() const { return iterator_ != nullptr; }
326
+ bool DidSeek() const { return iterator_ != nullptr && !target_; }
327
327
 
328
328
  void SeekToRange() {
329
329
  if (!iterator_) {
@@ -338,23 +338,19 @@ struct BaseIterator : public Closable {
338
338
  }
339
339
 
340
340
  void Seek(const rocksdb::Slice& 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
- }
357
- }
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
+ }
358
354
 
359
355
  rocksdb::Status Close() override {
360
356
  snapshot_.reset();
@@ -422,6 +418,7 @@ struct BaseIterator : public Closable {
422
418
  std::optional<rocksdb::PinnableSlice> lower_bound_;
423
419
  std::optional<rocksdb::PinnableSlice> upper_bound_;
424
420
  std::unique_ptr<rocksdb::Iterator> iterator_;
421
+ std::optional<std::string> target_;
425
422
  const bool reverse_;
426
423
  const int limit_;
427
424
  const bool fillCache_;
@@ -1275,7 +1272,7 @@ NAPI_METHOD(iterator_seek) {
1275
1272
  NAPI_STATUS_THROWS(GetValue(env, argv[1], target));
1276
1273
 
1277
1274
  iterator->first_ = true;
1278
- iterator->Seek(target); // TODO: Does seek causing blocking IO?
1275
+ iterator->Seek(target);
1279
1276
 
1280
1277
  return 0;
1281
1278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "10.0.6",
3
+ "version": "10.0.9",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",