JODA  0.13.1 (59b41972)
JSON On-Demand Analysis
DistinctAggregator.h
Go to the documentation of this file.
1 //
2 // Created by Nico Schäfer on 11/14/17.
3 //
4 
5 #ifndef JODA_DISTINCTAGGREGATOR_H
6 #define JODA_DISTINCTAGGREGATOR_H
7 
8 #include <unordered_set>
9 #include "IAggregator.h"
10 
11 namespace joda::query {
13  public:
14  DistinctAggregator(const std::string &toPointer,
15  std::vector<std::unique_ptr<IValueProvider>> &&params,
16  bool stringEnabled = true, bool boolEnabled = true,
17  bool numEnabled = true
18 
19  );
20  void merge(IAggregator *other) override;
21  RJValue terminate(RJMemoryPoolAlloc &alloc) override;
22  std::unique_ptr<IAggregator> duplicate() const override;
23  void accumulate(const RapidJsonDocument &json,
24  RJMemoryPoolAlloc &alloc) override;
25  const std::string getName() const override;
26 
27  static constexpr auto getName_() { return "DISTINCT"; }
28 
29  protected:
32  bool numEnabled;
33  std::unordered_set<std::string> strSet = {};
34  std::unordered_set<double> numSet = {};
35  bool hasTrue = false;
36  bool hasFalse = false;
37 };
38 } // namespace joda::query
39 
40 #endif // JODA_DISTINCTAGGREGATOR_H
rapidjson::MemoryPoolAllocator< RJBaseAlloc > RJMemoryPoolAlloc
Definition: RJFwd.h:26
rapidjson::GenericValue< RJChar, RJMemoryPoolAlloc > RJValue
Definition: RJFwd.h:29
Definition: RapidJsonDocument.h:22
Definition: DistinctAggregator.h:12
bool numEnabled
Definition: DistinctAggregator.h:32
bool boolEnabled
Definition: DistinctAggregator.h:31
bool stringEnabled
Definition: DistinctAggregator.h:30
const std::string getName() const override
Definition: DistinctAggregator.cpp:92
std::unique_ptr< IAggregator > duplicate() const override
Definition: DistinctAggregator.cpp:51
bool hasTrue
Definition: DistinctAggregator.h:35
std::unordered_set< double > numSet
Definition: DistinctAggregator.h:34
DistinctAggregator(const std::string &toPointer, std::vector< std::unique_ptr< IValueProvider >> &&params, bool stringEnabled=true, bool boolEnabled=true, bool numEnabled=true)
Definition: DistinctAggregator.cpp:56
bool hasFalse
Definition: DistinctAggregator.h:36
RJValue terminate(RJMemoryPoolAlloc &alloc) override
Definition: DistinctAggregator.cpp:19
void accumulate(const RapidJsonDocument &json, RJMemoryPoolAlloc &alloc) override
Definition: DistinctAggregator.cpp:67
void merge(IAggregator *other) override
Definition: DistinctAggregator.cpp:9
std::unordered_set< std::string > strSet
Definition: DistinctAggregator.h:33
static constexpr auto getName_()
Definition: DistinctAggregator.h:27
Definition: IAggregator.h:25
std::vector< std::unique_ptr< IValueProvider > > params
Definition: IAggregator.h:124
std::string toPointer
Definition: IAggregator.h:120
Definition: AttributeStatAggregator.h:12