@nxtedition/rocksdb 10.0.6 → 10.0.8
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,39 +323,39 @@ 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_) {
|
|
330
330
|
Init();
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
if (
|
|
334
|
-
|
|
335
|
-
} else {
|
|
336
|
-
iterator_->SeekToFirst();
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
void Seek(const rocksdb::Slice& target) {
|
|
341
|
-
if (!iterator_) {
|
|
342
|
-
Init();
|
|
343
|
-
}
|
|
333
|
+
if (target_) {
|
|
334
|
+
auto target = rocksdb::Slice(*target_);
|
|
344
335
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
336
|
+
if ((upper_bound_ && target.compare(*upper_bound_) >= 0) || (lower_bound_ && target.compare(*lower_bound_) < 0)) {
|
|
337
|
+
// TODO (fix): Why is this required? Seek should handle it?
|
|
338
|
+
// https://github.com/facebook/rocksdb/issues/9904
|
|
339
|
+
iterator_->SeekToLast();
|
|
340
|
+
if (iterator_->Valid()) {
|
|
341
|
+
iterator_->Next();
|
|
342
|
+
}
|
|
343
|
+
} else if (reverse_) {
|
|
344
|
+
iterator_->SeekForPrev(target);
|
|
345
|
+
} else {
|
|
346
|
+
iterator_->Seek(target);
|
|
351
347
|
}
|
|
348
|
+
|
|
349
|
+
target_ = std::nullopt;
|
|
352
350
|
} else if (reverse_) {
|
|
353
|
-
iterator_->
|
|
351
|
+
iterator_->SeekToLast();
|
|
354
352
|
} else {
|
|
355
|
-
iterator_->
|
|
353
|
+
iterator_->SeekToFirst();
|
|
356
354
|
}
|
|
357
355
|
}
|
|
358
356
|
|
|
357
|
+
void Seek(const rocksdb::Slice& target) { target_ = target.ToString(); }
|
|
358
|
+
|
|
359
359
|
rocksdb::Status Close() override {
|
|
360
360
|
snapshot_.reset();
|
|
361
361
|
iterator_.reset();
|
|
@@ -422,6 +422,7 @@ struct BaseIterator : public Closable {
|
|
|
422
422
|
std::optional<rocksdb::PinnableSlice> lower_bound_;
|
|
423
423
|
std::optional<rocksdb::PinnableSlice> upper_bound_;
|
|
424
424
|
std::unique_ptr<rocksdb::Iterator> iterator_;
|
|
425
|
+
std::optional<std::string> target_;
|
|
425
426
|
const bool reverse_;
|
|
426
427
|
const int limit_;
|
|
427
428
|
const bool fillCache_;
|
|
@@ -1275,7 +1276,7 @@ NAPI_METHOD(iterator_seek) {
|
|
|
1275
1276
|
NAPI_STATUS_THROWS(GetValue(env, argv[1], target));
|
|
1276
1277
|
|
|
1277
1278
|
iterator->first_ = true;
|
|
1278
|
-
iterator->Seek(target);
|
|
1279
|
+
iterator->Seek(target);
|
|
1279
1280
|
|
|
1280
1281
|
return 0;
|
|
1281
1282
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|