max_operator.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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. // Merge operator that picks the maximum operand, Comparison is based on
  7. // Slice::compare
  8. #pragma once
  9. #include "rocksdb/merge_operator.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. class Logger;
  12. class Slice;
  13. class MaxOperator : public MergeOperator {
  14. public:
  15. static const char* kClassName() { return "MaxOperator"; }
  16. static const char* kNickName() { return "max"; }
  17. const char* Name() const override { return kClassName(); }
  18. const char* NickName() const override { return kNickName(); }
  19. bool FullMergeV2(const MergeOperationInput& merge_in,
  20. MergeOperationOutput* merge_out) const override;
  21. bool PartialMerge(const Slice& /*key*/, const Slice& left_operand,
  22. const Slice& right_operand, std::string* new_value,
  23. Logger* /*logger*/) const override;
  24. bool PartialMergeMulti(const Slice& /*key*/,
  25. const std::deque<Slice>& operand_list,
  26. std::string* new_value,
  27. Logger* /*logger*/) const override;
  28. };
  29. } // namespace ROCKSDB_NAMESPACE