mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-30 22:41:48 +00:00
05e8854085
Summary: This diff introduces a new Merge operation into rocksdb. The purpose of this review is mostly getting feedback from the team (everyone please) on the design. Please focus on the four files under include/leveldb/, as they spell the client visible interface change. include/leveldb/db.h include/leveldb/merge_operator.h include/leveldb/options.h include/leveldb/write_batch.h Please go over local/my_test.cc carefully, as it is a concerete use case. Please also review the impelmentation files to see if the straw man implementation makes sense. Note that, the diff does pass all make check and truly supports forward iterator over db and a version of Get that's based on iterator. Future work: - Integration with compaction - A raw Get implementation I am working on a wiki that explains the design and implementation choices, but coding comes just naturally and I think it might be a good idea to share the code earlier. The code is heavily commented. Test Plan: run all local tests Reviewers: dhruba, heyongqiang Reviewed By: dhruba CC: leveldb, zshao, sheki, emayanke, MarkCallaghan Differential Revision: https://reviews.facebook.net/D9651
36 lines
869 B
C++
36 lines
869 B
C++
#include <memory>
|
|
#include "leveldb/slice.h"
|
|
#include "leveldb/merge_operator.h"
|
|
#include "utilities/merge_operators.h"
|
|
|
|
using namespace leveldb;
|
|
|
|
namespace { // anonymous namespace
|
|
|
|
// A merge operator that mimics Put semantics
|
|
class PutOperator : public MergeOperator {
|
|
public:
|
|
virtual void Merge(const Slice& key,
|
|
const Slice* existing_value,
|
|
const Slice& value,
|
|
std::string* new_value,
|
|
Logger* logger) const override {
|
|
// put basically only looks at the current value
|
|
new_value->assign(value.data(), value.size());
|
|
}
|
|
|
|
virtual const char* Name() const override {
|
|
return "PutOperator";
|
|
}
|
|
};
|
|
|
|
} // end of anonymous namespace
|
|
|
|
namespace leveldb {
|
|
|
|
std::shared_ptr<MergeOperator> MergeOperators::CreatePutOperator() {
|
|
return std::make_shared<PutOperator>();
|
|
}
|
|
|
|
}
|