@nxtedition/rocksdb 10.0.9 → 10.0.11

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 && !target_; }
326
+ bool DidSeek() const { return iterator_ != nullptr; }
327
327
 
328
328
  void SeekToRange() {
329
329
  if (!iterator_) {
@@ -338,19 +338,23 @@ struct BaseIterator : public Closable {
338
338
  }
339
339
 
340
340
  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
- }
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
+ }
354
358
 
355
359
  rocksdb::Status Close() override {
356
360
  snapshot_.reset();
@@ -418,7 +422,6 @@ struct BaseIterator : public Closable {
418
422
  std::optional<rocksdb::PinnableSlice> lower_bound_;
419
423
  std::optional<rocksdb::PinnableSlice> upper_bound_;
420
424
  std::unique_ptr<rocksdb::Iterator> iterator_;
421
- std::optional<std::string> target_;
422
425
  const bool reverse_;
423
426
  const int limit_;
424
427
  const bool fillCache_;
@@ -1271,8 +1274,18 @@ NAPI_METHOD(iterator_seek) {
1271
1274
  NapiSlice target;
1272
1275
  NAPI_STATUS_THROWS(GetValue(env, argv[1], target));
1273
1276
 
1274
- iterator->first_ = true;
1275
- iterator->Seek(target);
1277
+ struct State {};
1278
+
1279
+ runAsync<State>(
1280
+ std::string("leveldown.iterator.seek"), env, callback,
1281
+ [=](auto& state) {
1282
+ iterator->first_ = true;
1283
+ iterator->Seek(target);
1284
+ return iterator->Status();
1285
+ },
1286
+ [=](auto& state, auto env, auto& argv) {
1287
+ return napi_ok;
1288
+ });
1276
1289
 
1277
1290
  return 0;
1278
1291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "10.0.9",
3
+ "version": "10.0.11",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",