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

Method Get

src/leveldb/db/version_set.cc:325–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325Status Version::Get(const ReadOptions& options, const LookupKey& k,
326 std::string* value, GetStats* stats) {
327 stats->seek_file = nullptr;
328 stats->seek_file_level = -1;
329
330 struct State {
331 Saver saver;
332 GetStats* stats;
333 const ReadOptions* options;
334 Slice ikey;
335 FileMetaData* last_file_read;
336 int last_file_read_level;
337
338 VersionSet* vset;
339 Status s;
340 bool found;
341
342 static bool Match(void* arg, int level, FileMetaData* f) {
343 State* state = reinterpret_cast<State*>(arg);
344
345 if (state->stats->seek_file == nullptr &&
346 state->last_file_read != nullptr) {
347 // We have had more than one seek for this read. Charge the 1st file.
348 state->stats->seek_file = state->last_file_read;
349 state->stats->seek_file_level = state->last_file_read_level;
350 }
351
352 state->last_file_read = f;
353 state->last_file_read_level = level;
354
355 state->s = state->vset->table_cache_->Get(*state->options, f->number,
356 f->file_size, state->ikey,
357 &state->saver, SaveValue);
358 if (!state->s.ok()) {
359 state->found = true;
360 return false;
361 }
362 switch (state->saver.state) {
363 case kNotFound:
364 return true; // Keep searching in other files
365 case kFound:
366 state->found = true;
367 return false;
368 case kDeleted:
369 return false;
370 case kCorrupt:
371 state->s =
372 Status::Corruption("corrupted key for ", state->saver.user_key);
373 state->found = true;
374 return false;
375 }
376
377 // Not reached. Added to avoid false compilation warnings of
378 // "control reaches end of non-void function".
379 return false;
380 }
381 };
382

Callers 1

MatchMethod · 0.45

Calls 5

NotFoundFunction · 0.85
internal_keyMethod · 0.80
SliceClass · 0.50
user_comparatorMethod · 0.45
user_keyMethod · 0.45

Tested by

no test coverage detected