MCPcopy Create free account
hub / github.com/ElementsProject/elements / FindPrevUserEntry

Method FindPrevUserEntry

src/leveldb/db/db_iter.cc:236–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236void DBIter::FindPrevUserEntry() {
237 assert(direction_ == kReverse);
238
239 ValueType value_type = kTypeDeletion;
240 if (iter_->Valid()) {
241 do {
242 ParsedInternalKey ikey;
243 if (ParseKey(&ikey) && ikey.sequence <= sequence_) {
244 if ((value_type != kTypeDeletion) &&
245 user_comparator_->Compare(ikey.user_key, saved_key_) < 0) {
246 // We encountered a non-deleted value in entries for previous keys,
247 break;
248 }
249 value_type = ikey.type;
250 if (value_type == kTypeDeletion) {
251 saved_key_.clear();
252 ClearSavedValue();
253 } else {
254 Slice raw_value = iter_->value();
255 if (saved_value_.capacity() > raw_value.size() + 1048576) {
256 std::string empty;
257 swap(empty, saved_value_);
258 }
259 SaveKey(ExtractUserKey(iter_->key()), &saved_key_);
260 saved_value_.assign(raw_value.data(), raw_value.size());
261 }
262 }
263 iter_->Prev();
264 } while (iter_->Valid());
265 }
266
267 if (value_type == kTypeDeletion) {
268 // End
269 valid_ = false;
270 saved_key_.clear();
271 ClearSavedValue();
272 direction_ = kForward;
273 } else {
274 valid_ = true;
275 }
276}
277
278void DBIter::Seek(const Slice& target) {
279 direction_ = kForward;

Callers

nothing calls this directly

Calls 12

swapFunction · 0.85
ExtractUserKeyFunction · 0.85
ValidMethod · 0.45
CompareMethod · 0.45
clearMethod · 0.45
valueMethod · 0.45
capacityMethod · 0.45
sizeMethod · 0.45
keyMethod · 0.45
assignMethod · 0.45
dataMethod · 0.45
PrevMethod · 0.45

Tested by

no test coverage detected