1 /** 2 * A MergeOperator for rocksdb that implements string append. 3 * @author Deon Nicholas (dnicholas@fb.com) 4 * Copyright 2013 Facebook 5 */ 6 7 #pragma once 8 #include "rocksdb/merge_operator.h" 9 #include "rocksdb/slice.h" 10 11 namespace rocksdb { 12 13 class StringAppendOperator : public AssociativeMergeOperator { 14 public: 15 // Constructor: specify delimiter 16 explicit StringAppendOperator(char delim_char); 17 18 virtual bool Merge(const Slice& key, 19 const Slice* existing_value, 20 const Slice& value, 21 std::string* new_value, 22 Logger* logger) const override; 23 24 virtual const char* Name() const override; 25 26 private: 27 char delim_; // The delimiter is inserted between elements 28 29 }; 30 31 } // namespace rocksdb 32