test_agg_merge.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) 2017-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. #pragma once
  6. #include <algorithm>
  7. #include <cstddef>
  8. #include <memory>
  9. #include <unordered_map>
  10. #include "rocksdb/merge_operator.h"
  11. #include "rocksdb/slice.h"
  12. #include "rocksdb/utilities/agg_merge.h"
  13. #include "utilities/cassandra/cassandra_options.h"
  14. namespace ROCKSDB_NAMESPACE {
  15. class SumAggregator : public Aggregator {
  16. public:
  17. ~SumAggregator() override {}
  18. bool Aggregate(const std::vector<Slice>&, std::string& result) const override;
  19. bool DoPartialAggregate() const override { return true; }
  20. };
  21. class MultipleAggregator : public Aggregator {
  22. public:
  23. ~MultipleAggregator() override {}
  24. bool Aggregate(const std::vector<Slice>&, std::string& result) const override;
  25. bool DoPartialAggregate() const override { return true; }
  26. };
  27. class Last3Aggregator : public Aggregator {
  28. public:
  29. ~Last3Aggregator() override {}
  30. bool Aggregate(const std::vector<Slice>&, std::string& result) const override;
  31. };
  32. class EncodeHelper {
  33. public:
  34. static std::string EncodeFuncAndInt(const Slice& function_name,
  35. int64_t value);
  36. static std::string EncodeInt(int64_t value);
  37. static std::string EncodeList(const std::vector<Slice>& list);
  38. static std::string EncodeFuncAndList(const Slice& function_name,
  39. const std::vector<Slice>& list);
  40. };
  41. } // namespace ROCKSDB_NAMESPACE