| 69 | } |
| 70 | |
| 71 | bool Histogram::DecodeFromProto(const HistogramProto& proto) { |
| 72 | if ((proto.bucket_size() != proto.bucket_limit_size()) || |
| 73 | (proto.bucket_size() == 0)) { |
| 74 | return false; |
| 75 | } |
| 76 | min_ = proto.min(); |
| 77 | max_ = proto.max(); |
| 78 | num_ = proto.num(); |
| 79 | sum_ = proto.sum(); |
| 80 | sum_squares_ = proto.sum_squares(); |
| 81 | custom_bucket_limits_.clear(); |
| 82 | custom_bucket_limits_.insert(custom_bucket_limits_.end(), |
| 83 | proto.bucket_limit().begin(), |
| 84 | proto.bucket_limit().end()); |
| 85 | bucket_limits_ = custom_bucket_limits_; |
| 86 | buckets_.clear(); |
| 87 | buckets_.insert(buckets_.end(), proto.bucket().begin(), proto.bucket().end()); |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | void Histogram::Clear() { |
| 92 | min_ = bucket_limits_[bucket_limits_.size() - 1]; |