summaryrefslogtreecommitdiffstats
path: root/ml/Query.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-12-01 06:15:04 +0000
commite970e0b37b8bd7f246feb3f70c4136418225e434 (patch)
tree0b67c0ca45f56f2f9d9c5c2e725279ecdf52d2eb /ml/Query.h
parentAdding upstream version 1.31.0. (diff)
downloadnetdata-e970e0b37b8bd7f246feb3f70c4136418225e434.tar.xz
netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.zip
Adding upstream version 1.32.0.upstream/1.32.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ml/Query.h')
-rw-r--r--ml/Query.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/ml/Query.h b/ml/Query.h
new file mode 100644
index 000000000..cbaf6c297
--- /dev/null
+++ b/ml/Query.h
@@ -0,0 +1,49 @@
+#ifndef QUERY_H
+#define QUERY_H
+
+#include "ml-private.h"
+
+namespace ml {
+
+class Query {
+public:
+ Query(RRDDIM *RD) : RD(RD) {
+ Ops = &RD->state->query_ops;
+ }
+
+ time_t latestTime() {
+ return Ops->latest_time(RD);
+ }
+
+ time_t oldestTime() {
+ return Ops->oldest_time(RD);
+ }
+
+ void init(time_t AfterT, time_t BeforeT) {
+ Ops->init(RD, &Handle, AfterT, BeforeT);
+ }
+
+ bool isFinished() {
+ return Ops->is_finished(&Handle);
+ }
+
+ std::pair<time_t, storage_number> nextMetric() {
+ time_t CurrT;
+ storage_number SN = Ops->next_metric(&Handle, &CurrT);
+ return { CurrT, SN };
+ }
+
+ ~Query() {
+ Ops->finalize(&Handle);
+ }
+
+private:
+ RRDDIM *RD;
+
+ struct rrddim_volatile::rrddim_query_ops *Ops;
+ struct rrddim_query_handle Handle;
+};
+
+} // namespace ml
+
+#endif /* QUERY_H */