mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-29 09:36:17 +00:00
8f52972cf9
Summary: An arbitrary string can be used as a delimiter in StringAppend merge operator flavor. In particular, it allows using an empty string, combining binary values for the same key byte-to-byte one next to another. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8536 Reviewed By: mrambacher Differential Revision: D29962120 Pulled By: zhichao-cao fbshipit-source-id: 4ef5d846a47835cf428a11200409e30e2dbffc4f
32 lines
860 B
C++
32 lines
860 B
C++
/**
|
|
* A MergeOperator for rocksdb that implements string append.
|
|
* @author Deon Nicholas (dnicholas@fb.com)
|
|
* Copyright 2013 Facebook
|
|
*/
|
|
|
|
#pragma once
|
|
#include "rocksdb/merge_operator.h"
|
|
#include "rocksdb/slice.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
class StringAppendOperator : public AssociativeMergeOperator {
|
|
public:
|
|
// Constructor: specify delimiter
|
|
explicit StringAppendOperator(char delim_char);
|
|
explicit StringAppendOperator(const std::string& delim);
|
|
|
|
virtual bool 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:
|
|
std::string delim_; // The delimiter is inserted between elements
|
|
};
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|