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