Added missing instantiation for HistogramBuckets::computeTotalCount()
authorMike Kolupaev <kolmike@fb.com>
Wed, 23 Dec 2015 10:05:01 +0000 (02:05 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Wed, 23 Dec 2015 10:20:23 +0000 (02:20 -0800)
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
folly/stats/Histogram.h
folly/stats/Instantiations.cpp

index 925ab28e4ad0142199edb80d728635f198e4717e..0fab6ee5d6adffe4ee90a8b63862eb2ca3de6ead 100644 (file)
@@ -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) {
index 7b7ee1ed3afcc662e7f1dcb53c97f2759d7722e0..0142a8dd645cf1ad41fa480f67540aeffcb3d3b8 100644 (file)
@@ -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);
   }
index e6051a1c62e6da700911f1a176307902e673adbf..46ebf6f4483bbc04714771fcff4637bc08e68985 100644 (file)
@@ -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