blob: 5910b575b4a7210ca697d98f7c27b963a07000f2 (
plain)
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
|
#ifndef QUERY_H
#define QUERY_H
#include "ml-private.h"
namespace ml {
class Query {
public:
Query(RRDDIM *RD) : RD(RD), Initialized(false) {
Ops = RD->tiers[0]->query_ops;
}
time_t latestTime() {
return Ops->latest_time(RD->tiers[0]->db_metric_handle);
}
time_t oldestTime() {
return Ops->oldest_time(RD->tiers[0]->db_metric_handle);
}
void init(time_t AfterT, time_t BeforeT) {
Ops->init(RD->tiers[0]->db_metric_handle, &Handle, AfterT, BeforeT);
Initialized = true;
}
bool isFinished() {
return Ops->is_finished(&Handle);
}
~Query() {
if (Initialized)
Ops->finalize(&Handle);
}
std::pair<time_t, CalculatedNumber> nextMetric() {
STORAGE_POINT sp = Ops->next_metric(&Handle);
return { sp.start_time, sp.sum / sp.count };
}
private:
RRDDIM *RD;
bool Initialized;
struct storage_engine_query_ops *Ops;
struct storage_engine_query_handle Handle;
};
} // namespace ml
#endif /* QUERY_H */
|