NVIDIA DeepStream SDK API Reference

9.2 Release
includes/prometheus/detail/ckms_quantiles.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <array>
21 #include <cstddef>
22 #include <functional>
23 #include <vector>
24 
25 #include "prometheus/detail/core_export.h"
26 
27 // IWYU pragma: private, include "prometheus/summary.h"
28 
29 namespace prometheus {
30 namespace detail {
31 
33  public:
35  Quantile(double quantile, double error);
36 
37  double quantile;
38  double error;
39  double u;
40  double v;
41  };
42 
43  private:
44  struct Item {
45  double value;
46  int g;
47  int delta;
48 
49  Item(double value, int lower_delta, int delta);
50  };
51 
52  public:
53  explicit CKMSQuantiles(const std::vector<Quantile>& quantiles);
54 
55  void insert(double value);
56  double get(double q);
57  void reset();
58 
59  private:
60  double allowableError(int rank);
61  bool insertBatch();
62  void compress();
63 
64  private:
65  const std::reference_wrapper<const std::vector<Quantile>> quantiles_;
66 
67  std::size_t count_;
68  std::vector<Item> sample_;
69  std::array<double, 500> buffer_;
70  std::size_t buffer_count_;
71 };
72 
73 } // namespace detail
74 } // namespace prometheus
prometheus::detail::CKMSQuantiles
Definition: includes/prometheus/detail/ckms_quantiles.h:32
pydeepstreamdoc::node::NodeDoc::get
constexpr const char * get
Definition: service-maker/sources/python/src/bindings/docstrings/nodedoc.h:34
prometheus::detail::CKMSQuantiles::Quantile::u
double u
Definition: includes/prometheus/detail/ckms_quantiles.h:39
PROMETHEUS_CPP_CORE_EXPORT
#define PROMETHEUS_CPP_CORE_EXPORT
Definition: includes/prometheus/detail/core_export.h:31
prometheus::detail::CKMSQuantiles::Quantile::v
double v
Definition: includes/prometheus/detail/ckms_quantiles.h:40
prometheus::detail::CKMSQuantiles::Quantile
Definition: includes/prometheus/detail/ckms_quantiles.h:34
prometheus::detail::CKMSQuantiles::Quantile::quantile
double quantile
Definition: includes/prometheus/detail/ckms_quantiles.h:37
prometheus::detail::CKMSQuantiles::Quantile::error
double error
Definition: includes/prometheus/detail/ckms_quantiles.h:38
prometheus
Definition: includes/prometheus/check_names.h:25