blob: d565dc96374933791b566d66d0f36ea70443df96 (
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
|
// 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/grouping/hyperloglog.h>
#include <vespa/searchlib/expression/integerresultnode.h>
namespace search::aggregation {
/**
* Estimates the number of unique values of an expression that has
* been observed. This class keeps track of the raw data needed for
* estimation (the sketch). Actual estimation is done on the QR
* server.
*/
class ExpressionCountAggregationResult : public AggregationResult {
static const int PRECISION = 10;
HyperLogLog<PRECISION> _hll;
expression::Int64ResultNode _rank;
const ResultNode & onGetRank() const override { return _rank; }
void onPrepare(const ResultNode &, bool) override { }
public:
DECLARE_AGGREGATIONRESULT(ExpressionCountAggregationResult);
ExpressionCountAggregationResult();
~ExpressionCountAggregationResult();
void visitMembers(vespalib::ObjectVisitor &) const override {}
const Sketch<PRECISION, uint32_t> &getSketch() const { return _hll.getSketch(); }
};
}
|