Coverage Report

Created: 2024-09-08 07:17

/src/rocksdb/utilities/merge_operators/bytesxor.h
Line
Count
Source (jump to first uncovered line)
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2
//  This source code is licensed under both the GPLv2 (found in the
3
//  COPYING file in the root directory) and Apache 2.0 License
4
//  (found in the LICENSE.Apache file in the root directory).
5
6
#pragma once
7
8
#include <algorithm>
9
#include <memory>
10
#include <string>
11
12
#include "rocksdb/env.h"
13
#include "rocksdb/merge_operator.h"
14
#include "rocksdb/slice.h"
15
#include "util/coding.h"
16
#include "utilities/merge_operators.h"
17
18
namespace ROCKSDB_NAMESPACE {
19
20
// A 'model' merge operator that XORs two (same sized) array of bytes.
21
// Implemented as an AssociativeMergeOperator for simplicity and example.
22
class BytesXOROperator : public AssociativeMergeOperator {
23
 public:
24
  // XORs the two array of bytes one byte at a time and stores the result
25
  // in new_value. len is the number of xored bytes, and the length of new_value
26
  bool Merge(const Slice& key, const Slice* existing_value, const Slice& value,
27
             std::string* new_value, Logger* logger) const override;
28
29
2
  static const char* kClassName() { return "BytesXOR"; }
30
2
  static const char* kNickName() { return "bytesxor"; }
31
32
0
  const char* NickName() const override { return kNickName(); }
33
0
  const char* Name() const override { return kClassName(); }
34
35
  void XOR(const Slice* existing_value, const Slice& value,
36
           std::string* new_value) const;
37
};
38
39
}  // namespace ROCKSDB_NAMESPACE