diff options
Diffstat (limited to 'project2/basics/aggregates/countDistinct.cpp')
-rw-r--r-- | project2/basics/aggregates/countDistinct.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/project2/basics/aggregates/countDistinct.cpp b/project2/basics/aggregates/countDistinct.cpp new file mode 100644 index 0000000..b471911 --- /dev/null +++ b/project2/basics/aggregates/countDistinct.cpp @@ -0,0 +1,26 @@ +#include <aggregate.h> + +class CountDistinct : public ValueAggregate { + public: + CountDistinct(ScriptNodePtr s) : + ValueAggregate(s) + { + } + void reset() const + { + result.clear(); + } + void pushValue(const VariableType & v) const + { + result.insert(v); + } + VariableType resultValue() const + { + return result.size(); + } + private: + mutable std::set<VariableType> result; +}; + +DECLARE_LOADER("countdistinct", CountDistinct); + |