blob: 3e85726bb43049d773613a51a2f4b33e8264df04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "aggregationresult.h"
#include <vespa/searchlib/expression/floatresultnode.h>
#include <vespa/searchlib/expression/integerresultnode.h>
namespace search::aggregation {
// Aggregator that calculates the population standard deviation
class StandardDeviationAggregationResult : public AggregationResult
{
public:
DECLARE_AGGREGATIONRESULT(StandardDeviationAggregationResult);
StandardDeviationAggregationResult();
~StandardDeviationAggregationResult();
void visitMembers(vespalib::ObjectVisitor &visitor) const override;
double getSum() const noexcept { return _sum.getFloat(); }
double getSumOfSquared() const noexcept { return _sumOfSquared.getFloat(); }
uint64_t getCount() const noexcept { return _count; }
private:
const ResultNode& onGetRank() const noexcept override { return getStandardDeviation(); }
void onPrepare(const ResultNode&, bool) override { };
const expression::NumericResultNode& getStandardDeviation() const noexcept;
uint64_t _count;
expression::FloatResultNode _sum;
expression::FloatResultNode _sumOfSquared;
mutable expression::FloatResultNode::CP _stdDevScratchPad;
};
}
|