From 3740c2909f5d2da22be633fda642e789d2caaf9b Mon Sep 17 00:00:00 2001 From: Mike Kolupaev Date: Wed, 23 Dec 2015 02:05:01 -0800 Subject: [PATCH] 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 --- folly/stats/Histogram-defs.h | 2 +- folly/stats/Histogram.h | 4 ++-- folly/stats/Instantiations.cpp | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/folly/stats/Histogram-defs.h b/folly/stats/Histogram-defs.h index 925ab28e..0fab6ee5 100644 --- a/folly/stats/Histogram-defs.h +++ b/folly/stats/Histogram-defs.h @@ -63,7 +63,7 @@ unsigned int HistogramBuckets::getBucketIdx( template template -const uint64_t HistogramBuckets::computeTotalCount( +uint64_t HistogramBuckets::computeTotalCount( CountFn countFromBucket) const { uint64_t count = 0; for (unsigned int n = 0; n < buckets_.size(); ++n) { diff --git a/folly/stats/Histogram.h b/folly/stats/Histogram.h index 7b7ee1ed..0142a8dd 100644 --- a/folly/stats/Histogram.h +++ b/folly/stats/Histogram.h @@ -152,7 +152,7 @@ class HistogramBuckets { * @return Returns the total number of values stored across all buckets */ template - 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); } diff --git a/folly/stats/Instantiations.cpp b/folly/stats/Instantiations.cpp index e6051a1c..46ebf6f4 100644 --- a/folly/stats/Instantiations.cpp +++ b/folly/stats/Instantiations.cpp @@ -41,7 +41,8 @@ template class detail::HistogramBuckets::Bucket>; template class MultiLevelTimeSeries; template class TimeseriesHistogram; -// 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::Bucket> double pct, Histogram::CountFromBucket countFromBucket, Histogram::AvgFromBucket avgFromBucket) const; +template uint64_t detail::HistogramBuckets::Bucket> + ::computeTotalCount::CountFromBucket>( + Histogram::CountFromBucket countFromBucket) const; } // folly -- 2.34.1