Skip to main content

harmos_domain/model/storage/query/transform/
downsample.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17
18// Third Party Imports
19
20// Local Imports
21use super::FieldPath;
22use crate::MemorySize;
23use crate::model::storage::codec::{Code, Index, Nested, Optional, coded, product};
24
25/* === Constants === */
26
27/* === Macros === */
28
29product!(Downsample { max_rows: Index => 1, algorithm: Code<Algorithm> => 2, value: Optional<Nested<FieldPath>> => 3, axis: Optional<Nested<FieldPath>> => 4 });
30coded!(Algorithm { Decimate, Extrema, Lttb, LttbLog });
31
32/* === Type Aliases === */
33
34/* === Structs === */
35
36#[derive(Clone, Debug)]
37pub struct Downsample {
38    pub max_rows: usize,
39    pub algorithm: Algorithm,
40    pub value: Option<FieldPath>,
41    pub axis: Option<FieldPath>,
42}
43
44/* === Enums === */
45
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum Algorithm {
48    Decimate,
49    Extrema,
50    Lttb,
51    LttbLog,
52}
53
54/* === Traits === */
55
56/* === Implementations === */
57
58impl MemorySize for Downsample {
59    fn memory_size(&self) -> usize {
60        std::mem::size_of::<Self>()
61            + self.value.memory_size().saturating_sub(std::mem::size_of_val(&self.value))
62            + self.axis.memory_size().saturating_sub(std::mem::size_of_val(&self.axis))
63    }
64}
65
66/* === Public Functions === */
67
68/* === Private Functions === */
69
70/* === Tests === */