def _update_explicit_bucket_count(a_float, dist):
"""Adds `a_float` to `dist`, updating its explicit buckets.
Args:
a_float (float): a new value
dist (:class:`endpoints_management.gen.servicecontrol_v1_messages.Distribution`):
the Distribution being updated
Raises:
ValueError: if `dist` does not already have explict buckets defined
ValueError: if there are not enough bucket count fields in `dist`
"""
buckets = dist.explicitBuckets
if buckets is None:
raise ValueError(_BAD_UNSET_BUCKETS % (u'explicit buckets'))
bucket_counts = dist.bucketCounts
bounds = buckets.bounds
if len(bucket_counts) < len(bounds) + 1:
raise ValueError(_BAD_LOW_BUCKET_COUNT)
bucket_counts[bisect.bisect(bounds, a_float)] += 1
distribution.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录