| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_RRDDIMMEM_H |
| 4 | #define NETDATA_RRDDIMMEM_H |
| 5 | |
| 6 | #include "database/rrd.h" |
| 7 | |
| 8 | struct mem_collect_handle { |
| 9 | struct storage_collect_handle common; // has to be first item |
| 10 | |
| 11 | STORAGE_METRIC_HANDLE *smh; |
| 12 | RRDDIM *rd; |
| 13 | }; |
| 14 | |
| 15 | struct mem_query_handle { |
| 16 | STORAGE_METRIC_HANDLE *smh; |
| 17 | time_t dt; |
| 18 | time_t next_timestamp; |
| 19 | time_t last_timestamp; |
| 20 | time_t slot_timestamp; |
| 21 | size_t slot; |
| 22 | size_t last_slot; |
| 23 | }; |
| 24 | |
| 25 | STORAGE_METRIC_HANDLE *rrddim_metric_get_or_create(RRDDIM *rd, STORAGE_INSTANCE *si); |
| 26 | STORAGE_METRIC_HANDLE *rrddim_metric_get_by_id(STORAGE_INSTANCE *si, UUIDMAP_ID id); |
| 27 | STORAGE_METRIC_HANDLE *rrddim_metric_get_by_uuid(STORAGE_INSTANCE *si, nd_uuid_t *uuid); |
| 28 | STORAGE_METRIC_HANDLE *rrddim_metric_dup(STORAGE_METRIC_HANDLE *smh); |
| 29 | void rrddim_metric_release(STORAGE_METRIC_HANDLE *smh); |
| 30 | |
| 31 | bool rrddim_metric_retention_by_id(STORAGE_INSTANCE *si, UUIDMAP_ID id, time_t *first_entry_s, time_t *last_entry_s); |
| 32 | bool rrddim_metric_retention_by_uuid(STORAGE_INSTANCE *si, nd_uuid_t *uuid, time_t *first_entry_s, time_t *last_entry_s); |
| 33 | void rrddim_retention_delete_by_id(STORAGE_INSTANCE *si, UUIDMAP_ID id); |
| 34 | |
| 35 | STORAGE_METRICS_GROUP *rrddim_metrics_group_get(STORAGE_INSTANCE *si, nd_uuid_t *uuid); |
| 36 | void rrddim_metrics_group_release(STORAGE_INSTANCE *si, STORAGE_METRICS_GROUP *smg); |
| 37 | |
| 38 | STORAGE_COLLECT_HANDLE *rrddim_collect_init(STORAGE_METRIC_HANDLE *smh, uint32_t update_every, STORAGE_METRICS_GROUP *smg); |
| 39 | void rrddim_store_metric_change_collection_frequency(STORAGE_COLLECT_HANDLE *sch, int update_every); |
| 40 | void rrddim_collect_store_metric(STORAGE_COLLECT_HANDLE *sch, usec_t point_in_time_ut, NETDATA_DOUBLE n, |
| 41 | NETDATA_DOUBLE min_value, |
| 42 | NETDATA_DOUBLE max_value, |
| 43 | uint16_t count, |
| 44 | uint16_t anomaly_count, |
| 45 | SN_FLAGS flags); |
| 46 | void rrddim_store_metric_flush(STORAGE_COLLECT_HANDLE *sch); |
| 47 | int rrddim_collect_finalize(STORAGE_COLLECT_HANDLE *sch); |
| 48 | |
| 49 | void rrddim_query_init(STORAGE_METRIC_HANDLE *smh, struct storage_engine_query_handle *seqh, time_t start_time_s, time_t end_time_s, STORAGE_PRIORITY priority); |
| 50 | STORAGE_POINT rrddim_query_next_metric(struct storage_engine_query_handle *seqh); |
| 51 | int rrddim_query_is_finished(struct storage_engine_query_handle *seqh); |
| 52 | void rrddim_query_finalize(struct storage_engine_query_handle *seqh); |
| 53 | time_t rrddim_query_latest_time_s(STORAGE_METRIC_HANDLE *smh); |
| 54 | time_t rrddim_query_oldest_time_s(STORAGE_METRIC_HANDLE *smh); |
| 55 | time_t rrddim_query_align_to_optimal_before(struct storage_engine_query_handle *seqh); |
| 56 | |
| 57 | #endif |