Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/db/memtable.cc
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | void MemTable::Add(SequenceNumber s, ValueType type, | ||||
char* buf = arena_.Allocate(encoded_len); | char* buf = arena_.Allocate(encoded_len); | ||||
char* p = EncodeVarint32(buf, internal_key_size); | char* p = EncodeVarint32(buf, internal_key_size); | ||||
memcpy(p, key.data(), key_size); | memcpy(p, key.data(), key_size); | ||||
p += key_size; | p += key_size; | ||||
EncodeFixed64(p, (s << 8) | type); | EncodeFixed64(p, (s << 8) | type); | ||||
p += 8; | p += 8; | ||||
p = EncodeVarint32(p, val_size); | p = EncodeVarint32(p, val_size); | ||||
memcpy(p, value.data(), val_size); | memcpy(p, value.data(), val_size); | ||||
assert((p + val_size) - buf == encoded_len); | assert(p + val_size == buf + encoded_len); | ||||
table_.Insert(buf); | table_.Insert(buf); | ||||
} | } | ||||
bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) { | bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) { | ||||
Slice memkey = key.memtable_key(); | Slice memkey = key.memtable_key(); | ||||
Table::Iterator iter(&table_); | Table::Iterator iter(&table_); | ||||
iter.Seek(memkey.data()); | iter.Seek(memkey.data()); | ||||
if (iter.Valid()) { | if (iter.Valid()) { | ||||
Show All 33 Lines |