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 | |
17 | #include <folly/stats/QuantileEstimator-defs.h> |
18 | |
19 | namespace folly { |
20 | namespace detail { |
21 | |
22 | QuantileEstimates estimatesFromDigest( |
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 | |
38 | template class SimpleQuantileEstimator<std::chrono::steady_clock>; |
39 | template class SlidingWindowQuantileEstimator<std::chrono::steady_clock>; |
40 | |
41 | } // namespace folly |
42 |