Skip to content

Commit

Permalink
Always pass MergeContext as pointer, not reference
Browse files Browse the repository at this point in the history
Summary: To follow the coding convention and make sure when passing reference as a parameter it is also const, pass MergeContext as a pointer to mem tables.

Test Plan: make all check

Reviewers: ljin, igor

Reviewed By: igor

Subscribers: leveldb, dhruba, yhchiang

Differential Revision: https://reviews.facebook.net/D23085
  • Loading branch information
siying committed Sep 9, 2014
1 parent d343c3f commit 06d9862
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3449,10 +3449,10 @@ Status DBImpl::GetImpl(const ReadOptions& options,
LookupKey lkey(key, snapshot);
PERF_TIMER_STOP(get_snapshot_time);

if (sv->mem->Get(lkey, value, &s, merge_context)) {
if (sv->mem->Get(lkey, value, &s, &merge_context)) {
// Done
RecordTick(stats_, MEMTABLE_HIT);
} else if (sv->imm->Get(lkey, value, &s, merge_context)) {
} else if (sv->imm->Get(lkey, value, &s, &merge_context)) {
// Done
RecordTick(stats_, MEMTABLE_HIT);
} else {
Expand Down Expand Up @@ -3537,9 +3537,9 @@ std::vector<Status> DBImpl::MultiGet(
assert(mgd_iter != multiget_cf_data.end());
auto mgd = mgd_iter->second;
auto super_version = mgd->super_version;
if (super_version->mem->Get(lkey, value, &s, merge_context)) {
if (super_version->mem->Get(lkey, value, &s, &merge_context)) {
// Done
} else if (super_version->imm->Get(lkey, value, &s, merge_context)) {
} else if (super_version->imm->Get(lkey, value, &s, &merge_context)) {
// Done
} else {
super_version->current->Get(options, lkey, value, &s, &merge_context);
Expand Down
2 changes: 1 addition & 1 deletion db/db_impl_readonly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Status DBImplReadOnly::Get(const ReadOptions& read_options,
SuperVersion* super_version = cfd->GetSuperVersion();
MergeContext merge_context;
LookupKey lkey(key, snapshot);
if (super_version->mem->Get(lkey, value, &s, merge_context)) {
if (super_version->mem->Get(lkey, value, &s, &merge_context)) {
} else {
super_version->current->Get(read_options, lkey, value, &s, &merge_context);
}
Expand Down
4 changes: 2 additions & 2 deletions db/memtable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static bool SaveValue(void* arg, const char* entry) {
}

bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
MergeContext& merge_context) {
MergeContext* merge_context) {
// The sequence number is updated synchronously in version_set.h
if (IsEmpty()) {
// Avoiding recording stats for speed.
Expand All @@ -454,7 +454,7 @@ bool MemTable::Get(const LookupKey& key, std::string* value, Status* s,
saver.value = value;
saver.status = s;
saver.mem = this;
saver.merge_context = &merge_context;
saver.merge_context = merge_context;
saver.merge_operator = ioptions_.merge_operator;
saver.logger = ioptions_.info_log;
saver.inplace_update_support = moptions_.inplace_update_support;
Expand Down
2 changes: 1 addition & 1 deletion db/memtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MemTable {
// store MergeInProgress in s, and return false.
// Else, return false.
bool Get(const LookupKey& key, std::string* value, Status* s,
MergeContext& merge_context);
MergeContext* merge_context);

// Attempts to update the new_value inplace, else does normal Add
// Pseudocode
Expand Down
2 changes: 1 addition & 1 deletion db/memtable_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int MemTableList::size() const {
// Return the most recent value found, if any.
// Operands stores the list of merge operations to apply, so far.
bool MemTableListVersion::Get(const LookupKey& key, std::string* value,
Status* s, MergeContext& merge_context) {
Status* s, MergeContext* merge_context) {
for (auto& memtable : memlist_) {
if (memtable->Get(key, value, s, merge_context)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion db/memtable_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MemTableListVersion {
// Search all the memtables starting from the most recent one.
// Return the most recent value found, if any.
bool Get(const LookupKey& key, std::string* value, Status* s,
MergeContext& merge_context);
MergeContext* merge_context);

void AddIterators(const ReadOptions& options,
std::vector<Iterator*>* iterator_list, Arena* arena);
Expand Down

0 comments on commit 06d9862

Please sign in to comment.