accd3debbb
Summary: Implemented the StringAppendOperator class (subclass of MergeOperator). Found in utilities/merge_operators/string_append/stringappend.{h,cc} It is a rocksdb Merge Operator that supports string/list concatenation with a configurable delimiter. The tests are found in .../stringappend_test.cc. It implements a map : key -> (list of strings), with core operations Append(list_key,val) and Get(list_key). Test Plan: 1. Navigate to your rocksdb repository 2. Execute: make stringappend_test (to compile) 3. Execute: ./stringappend_test (to run the tests) 4. Execute: make all check (to test the ENTIRE rocksdb codebase / regression) Reviewers: haobo, dhruba, zshao Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D10737
32 lines
759 B
C++
32 lines
759 B
C++
/**
|
|
* A MergeOperator for rocksdb/leveldb that implements string append.
|
|
* @author Deon Nicholas (dnicholas@fb.com)
|
|
* Copyright 2013 Facebook
|
|
*/
|
|
|
|
#include "leveldb/merge_operator.h"
|
|
#include "leveldb/slice.h"
|
|
|
|
namespace leveldb {
|
|
|
|
class StringAppendOperator : public MergeOperator {
|
|
public:
|
|
|
|
StringAppendOperator(char delim_char); /// Constructor: specify delimiter
|
|
|
|
virtual void Merge(const Slice& key,
|
|
const Slice* existing_value,
|
|
const Slice& value,
|
|
std::string* new_value,
|
|
Logger* logger) const override;
|
|
|
|
virtual const char* Name() const override;
|
|
|
|
private:
|
|
char delim_; // The delimiter is inserted between elements
|
|
|
|
};
|
|
|
|
} // namespace leveldb
|
|
|