Skip to main content

harmos_domain/model/storage/query/transform/
histogram.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::{Float, Many, Nested, product};
26
27/* === Constants === */
28
29/* === Macros === */
30
31product!(Histogram { field: Nested<FieldPath> => 1, edges: Many<Float> => 2 });
32
33/* === Type Aliases === */
34
35/* === Structs === */
36
37#[derive(Clone, Debug)]
38pub struct Histogram {
39    pub field: FieldPath,
40    pub edges: Vec<f64>,
41}
42
43/* === Enums === */
44
45/* === Traits === */
46
47/* === Implementations === */
48
49impl MemorySize for Histogram {
50    fn memory_size(&self) -> usize {
51        std::mem::size_of::<Self>()
52            + self.field.memory_size().saturating_sub(std::mem::size_of_val(&self.field))
53            + self.edges.capacity().saturating_mul(8)
54    }
55}
56
57/* === Public Functions === */
58
59/* === Private Functions === */
60
61/* === Tests === */