aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/core/statistics/events.h
blob: 49dc1750cbb273a487b2301bce9794c86398ac28 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once

#include <ydb/core/base/events.h>
#include <ydb/core/scheme/scheme_pathid.h>
#include <ydb/core/protos/statistics.pb.h>
#include <library/cpp/actors/core/events.h>

namespace NKikimr {
namespace NStat {

struct TStatSimple {
    ui64 RowCount = 0;
    ui64 BytesSize = 0;
};

struct TStatHyperLogLog {
    // TODO:
};

// TODO: other stats
enum EStatType {
    SIMPLE = 0,
    HYPER_LOG_LOG = 1,
    // TODO...
};

struct TRequest {
    EStatType StatType;
    TPathId PathId;
    std::optional<TString> ColumnName; // not used for simple stat
};

struct TResponse {
    bool Success = true;
    TRequest Req;
    std::variant<TStatSimple, TStatHyperLogLog> Statistics;
};

struct TEvStatistics {
    enum EEv {
        EvGetStatistics = EventSpaceBegin(TKikimrEvents::ES_STATISTICS),
        EvGetStatisticsResult,

        EvGetStatisticsFromSS, // deprecated
        EvGetStatisticsFromSSResult, // deprecated

        EvBroadcastStatistics,
        EvRegisterNode,

        EvConfigureAggregator,

        EvEnd
    };

    struct TEvGetStatistics : public TEventLocal<TEvGetStatistics, EvGetStatistics> {
        std::vector<TRequest> StatRequests;
    };

    struct TEvGetStatisticsResult : public TEventLocal<TEvGetStatisticsResult, EvGetStatisticsResult> {
        bool Success = true;
        std::vector<TResponse> StatResponses;
    };

    struct TEvBroadcastStatistics : public TEventPreSerializedPB<
        TEvBroadcastStatistics,
        NKikimrStat::TEvBroadcastStatistics,
        EvBroadcastStatistics>
    {};

    struct TEvRegisterNode : public TEventPB<
        TEvRegisterNode,
        NKikimrStat::TEvRegisterNode,
        EvRegisterNode>
    {};

    struct TEvConfigureAggregator : public TEventPB<
        TEvConfigureAggregator,
        NKikimrStat::TEvConfigureAggregator,
        EvConfigureAggregator>
    {
        TEvConfigureAggregator() = default;

        explicit TEvConfigureAggregator(const TString& database) {
            Record.SetDatabase(database);
        }
    };

};

} // NStat
} // NKikimr