summaryrefslogtreecommitdiffstats
path: root/database/engine/page.h
blob: 32c87c580722729e96523ab067b4f1cff107e808 (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
52
53
54
55
56
57
58
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef DBENGINE_PAGE_H
#define DBENGINE_PAGE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "libnetdata/libnetdata.h"

typedef struct pgd_cursor {
    struct pgd *pgd;
    uint32_t position;
    uint32_t slots;

    gorilla_reader_t gr;
} PGDC;

#include "rrdengine.h"

typedef struct pgd PGD;

#define PGD_EMPTY (PGD *)(-1)

void pgd_init_arals(void);

PGD *pgd_create(uint8_t type, uint32_t slots);
PGD *pgd_create_from_disk_data(uint8_t type, void *base, uint32_t size);
void pgd_free(PGD *pg);

uint32_t pgd_type(PGD *pg);
bool pgd_is_empty(PGD *pg);
uint32_t pgd_slots_used(PGD *pg);

uint32_t pgd_memory_footprint(PGD *pg);
uint32_t pgd_disk_footprint(PGD *pg);

void pgd_copy_to_extent(PGD *pg, uint8_t *dst, uint32_t dst_size);

void pgd_append_point(PGD *pg,
                      usec_t point_in_time_ut,
                      NETDATA_DOUBLE n,
                      NETDATA_DOUBLE min_value,
                      NETDATA_DOUBLE max_value,
                      uint16_t count,
                      uint16_t anomaly_count,
                      SN_FLAGS flags,
                      uint32_t expected_slot);

void pgdc_reset(PGDC *pgdc, PGD *pgd, uint32_t position);
bool pgdc_get_next_point(PGDC *pgdc, uint32_t expected_position, STORAGE_POINT *sp);

#ifdef __cplusplus
}
#endif

#endif // DBENGINE_PAGE_H