Commit 3740c290 authored by Mike Kolupaev's avatar Mike Kolupaev Committed by facebook-github-bot-1

Added missing instantiation for HistogramBuckets::computeTotalCount()

Summary:
D2078239 added a template method to HistogramBuckets but didn't add an instantiation for it, similar to getPercentileBucketIdx() and getPercentileEstimate() (see comment in Instantiations.cpp). This diff adds it, making `computeTotalCount()` usable without including `Histogram-defs.h`.

Also removes the weird `const` in return type.

Reviewed By: simpkins

Differential Revision: D2783534

fb-gh-sync-id: 9226489820116e0cbcb1f6a631b389439558061e
parent 6e8dcd61
......@@ -63,7 +63,7 @@ unsigned int HistogramBuckets<T, BucketType>::getBucketIdx(
template <typename T, typename BucketType>
template <typename CountFn>
const uint64_t HistogramBuckets<T, BucketType>::computeTotalCount(
uint64_t HistogramBuckets<T, BucketType>::computeTotalCount(
CountFn countFromBucket) const {
uint64_t count = 0;
for (unsigned int n = 0; n < buckets_.size(); ++n) {
......
......@@ -152,7 +152,7 @@ class HistogramBuckets {
* @return Returns the total number of values stored across all buckets
*/
template <typename CountFn>
const uint64_t computeTotalCount(CountFn countFromBucket) const;
uint64_t computeTotalCount(CountFn countFromBucket) const;
/**
* Determine which bucket the specified percentile falls into.
......@@ -393,7 +393,7 @@ class Histogram {
*
* Runs in O(numBuckets)
*/
const uint64_t computeTotalCount() const {
uint64_t computeTotalCount() const {
CountFromBucket countFn;
return buckets_.computeTotalCount(countFn);
}
......
......@@ -41,7 +41,8 @@ template class detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>;
template class MultiLevelTimeSeries<int64_t>;
template class TimeseriesHistogram<int64_t>;
// Histogram::getPercentileBucketIdx() and Histogram::getPercentileEstimate()
// Histogram::getPercentileBucketIdx(), Histogram::getPercentileEstimate()
// and Histogram::computeTotalCount()
// are implemented using template methods. Instantiate the default versions of
// these methods too, so anyone using them won't also need to explicitly
// include Histogram-defs.h
......@@ -58,5 +59,8 @@ template int64_t detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>
double pct,
Histogram<int64_t>::CountFromBucket countFromBucket,
Histogram<int64_t>::AvgFromBucket avgFromBucket) const;
template uint64_t detail::HistogramBuckets<int64_t, Histogram<int64_t>::Bucket>
::computeTotalCount<Histogram<int64_t>::CountFromBucket>(
Histogram<int64_t>::CountFromBucket countFromBucket) const;
} // folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment