fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
869 B
36 lines
869 B
12 years ago
|
#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>();
|
||
|
}
|
||
|
|
||
|
}
|