Expose more functions/constructors on BucketedTimeSeries
[folly.git] / folly / stats / BucketedTimeSeries.h
index 14468d6175babcaf6f241d2c6ffff6ae90470ebe..a31904daf6652819edb949b1c562e9a91cba3b15 100644 (file)
@@ -81,6 +81,18 @@ class BucketedTimeSeries {
    */
   BucketedTimeSeries(size_t numBuckets, Duration duration);
 
+  /*
+   * Create a new BucketedTimeSeries.
+   *
+   * This constructor is used to reconstruct a timeseries using
+   * previously saved data
+   */
+  BucketedTimeSeries(
+      TimePoint theFirstTime,
+      TimePoint theLatestTime,
+      Duration maxDuration,
+      const std::vector<Bucket>& bucketsList);
+
   /*
    * Adds the value 'val' at time 'now'
    *
@@ -192,6 +204,29 @@ class BucketedTimeSeries {
     return firstTime_ > latestTime_;
   }
 
+  /*
+   * Returns time of first update() since clear()/constructor.
+   * Note that the returned value is only meaningful when empty() is false.
+   */
+  TimePoint firstTime() const {
+    return firstTime_;
+  }
+
+  /*
+   * Returns time of last update().
+   * Note that the returned value is only meaningful when empty() is false.
+   */
+  TimePoint latestTime() const {
+    return latestTime_;
+  }
+
+  /*
+   * Returns actual buckets of values
+   */
+  const std::vector<Bucket>& buckets() const {
+    return buckets_;
+  }
+
   /*
    * Get the amount of time tracked by this timeseries.
    *