Skip to main content

libdd_ddsketch/
pb.rs

1// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
2// SPDX-License-Identifier: Apache-2.0
3
4// This file is @generated by prost-build.
5/// A DDSketch is essentially a histogram that partitions the range of positive values into an infinite number of
6/// indexed bins whose size grows exponentially. It keeps track of the number of values (or possibly floating-point
7/// weights) added to each bin. Negative values are partitioned like positive values, symmetrically to zero.
8/// The value zero as well as its close neighborhood that would be mapped to extreme bin indexes is mapped to a specific
9/// counter.
10#[derive(Clone, PartialEq, ::prost::Message)]
11pub struct DdSketch {
12    /// The mapping between positive values and the bin indexes they belong to.
13    #[prost(message, optional, tag = "1")]
14    pub mapping: ::core::option::Option<IndexMapping>,
15    /// The store for keeping track of positive values.
16    #[prost(message, optional, tag = "2")]
17    pub positive_values: ::core::option::Option<Store>,
18    /// The store for keeping track of negative values. A negative value v is mapped using its positive opposite -v.
19    #[prost(message, optional, tag = "3")]
20    pub negative_values: ::core::option::Option<Store>,
21    /// The count for the value zero and its close neighborhood (whose width depends on the mapping).
22    #[prost(double, tag = "4")]
23    pub zero_count: f64,
24}
25/// How to map positive values to the bins they belong to.
26#[derive(Clone, Copy, PartialEq, ::prost::Message)]
27pub struct IndexMapping {
28    /// The gamma parameter of the mapping, such that bin index that a value v belongs to is roughly equal to
29    /// log(v)/log(gamma).
30    #[prost(double, tag = "1")]
31    pub gamma: f64,
32    /// An offset that can be used to shift all bin indexes.
33    #[prost(double, tag = "2")]
34    pub index_offset: f64,
35    /// To speed up the computation of the index a value belongs to, the computation of the log may be approximated using
36    /// the fact that the log to the base 2 of powers of 2 can be computed at a low cost from the binary representation of
37    /// the input value. Other values can be approximated by interpolating between successive powers of 2 (linearly,
38    /// quadratically or cubically).
39    /// NONE means that the log is to be computed exactly (no interpolation).
40    #[prost(enumeration = "index_mapping::Interpolation", tag = "3")]
41    pub interpolation: i32,
42}
43/// Nested message and enum types in `IndexMapping`.
44pub mod index_mapping {
45    #[derive(
46        Clone,
47        Copy,
48        Debug,
49        PartialEq,
50        Eq,
51        Hash,
52        PartialOrd,
53        Ord,
54        ::prost::Enumeration
55    )]
56    #[repr(i32)]
57    pub enum Interpolation {
58        None = 0,
59        Linear = 1,
60        Quadratic = 2,
61        Cubic = 3,
62    }
63    impl Interpolation {
64        /// String value of the enum field names used in the ProtoBuf definition.
65        ///
66        /// The values are not transformed in any way and thus are considered stable
67        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
68        pub fn as_str_name(&self) -> &'static str {
69            match self {
70                Self::None => "NONE",
71                Self::Linear => "LINEAR",
72                Self::Quadratic => "QUADRATIC",
73                Self::Cubic => "CUBIC",
74            }
75        }
76        /// Creates an enum from field names used in the ProtoBuf definition.
77        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
78            match value {
79                "NONE" => Some(Self::None),
80                "LINEAR" => Some(Self::Linear),
81                "QUADRATIC" => Some(Self::Quadratic),
82                "CUBIC" => Some(Self::Cubic),
83                _ => None,
84            }
85        }
86    }
87}
88/// A Store maps bin indexes to their respective counts.
89/// Counts can be encoded sparsely using binCounts, but also in a contiguous way using contiguousBinCounts and
90/// contiguousBinIndexOffset. Given that non-empty bins are in practice usually contiguous or close to one another, the
91/// latter contiguous encoding method is usually more efficient than the sparse one.
92/// Both encoding methods can be used conjointly. If a bin appears in both the sparse and the contiguous encodings, its
93/// count value is the sum of the counts in each encodings.
94#[derive(Clone, PartialEq, ::prost::Message)]
95pub struct Store {
96    /// The bin counts, encoded sparsely.
97    #[prost(map = "sint32, double", tag = "1")]
98    pub bin_counts: ::std::collections::HashMap<i32, f64>,
99    /// The bin counts, encoded contiguously. The values of contiguousBinCounts are the counts for the bins of indexes
100    /// o, o+1, o+2, etc., where o is contiguousBinIndexOffset.
101    #[prost(double, repeated, tag = "2")]
102    pub contiguous_bin_counts: ::prost::alloc::vec::Vec<f64>,
103    #[prost(sint32, tag = "3")]
104    pub contiguous_bin_index_offset: i32,
105}