proxygen
QuantileEstimator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 namespace folly {
20 namespace detail {
21 
23  const TDigest& digest,
24  Range<const double*> quantiles) {
25  QuantileEstimates result;
26  result.quantiles.reserve(quantiles.size());
27  result.sum = digest.sum();
28  result.count = digest.count();
29  for (auto it = quantiles.begin(); it != quantiles.end(); ++it) {
30  result.quantiles.push_back(
31  std::make_pair(*it, digest.estimateQuantile(*it)));
32  }
33  return result;
34 }
35 
36 } // namespace detail
37 
40 
41 } // namespace folly
constexpr size_type size() const
Definition: Range.h:431
double estimateQuantile(double q) const
Definition: TDigest.cpp:312
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
double sum() const
Definition: TDigest.h:114
double count() const
Definition: TDigest.h:118
constexpr Iter end() const
Definition: Range.h:455
constexpr Iter begin() const
Definition: Range.h:452
QuantileEstimates estimatesFromDigest(const TDigest &digest, Range< const double * > quantiles)
std::vector< std::pair< double, double > > quantiles