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

Method Get

src/leveldb/db/memtable.cc:101–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) {
102 Slice memkey = key.memtable_key();
103 Table::Iterator iter(&table_);
104 iter.Seek(memkey.data());
105 if (iter.Valid()) {
106 // entry format is:
107 // klength varint32
108 // userkey char[klength]
109 // tag uint64
110 // vlength varint32
111 // value char[vlength]
112 // Check that it belongs to same user key. We do not check the
113 // sequence number since the Seek() call above should have skipped
114 // all entries with overly large sequence numbers.
115 const char* entry = iter.key();
116 uint32_t key_length;
117 const char* key_ptr = GetVarint32Ptr(entry, entry + 5, &key_length);
118 if (comparator_.comparator.user_comparator()->Compare(
119 Slice(key_ptr, key_length - 8), key.user_key()) == 0) {
120 // Correct user key
121 const uint64_t tag = DecodeFixed64(key_ptr + key_length - 8);
122 switch (static_cast<ValueType>(tag & 0xff)) {
123 case kTypeValue: {
124 Slice v = GetLengthPrefixedSlice(key_ptr + key_length);
125 value->assign(v.data(), v.size());
126 return true;
127 }
128 case kTypeDeletion:
129 *s = Status::NotFound(Slice());
130 return true;
131 }
132 }
133 }
134 return false;
135}
136
137} // namespace leveldb

Callers

nothing calls this directly

Calls 15

GetVarint32PtrFunction · 0.85
DecodeFixed64Function · 0.85
NotFoundFunction · 0.85
memtable_keyMethod · 0.80
GetLengthPrefixedSliceFunction · 0.70
SliceClass · 0.50
SeekMethod · 0.45
dataMethod · 0.45
ValidMethod · 0.45
keyMethod · 0.45
CompareMethod · 0.45
user_comparatorMethod · 0.45

Tested by

no test coverage detected