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