Proposal
In the model/histogram package, in the Histogram and FloatHistogram types add a slice called customBounds
// customBounds holds the custom upper bounds for bucket definitions, otherwise nil.
// The upper bound +Inf is implicit, need not be stored.
// This slice is interned, to be treated as immutable and copied by reference.
// These numbers should be sorted from smallest to biggest.
customBounds []float64
Also add a constant to define the schema number that means custom buckets are in use. E.g. 127.
const CustomBucketsSchema = 127
In general the schema number dictates the semantics of the operations. When reading / validating the data it is ok to ignore the negative spans/counts/deltas and zero bucket information if schema == CustomBucketsSchema. Conversely it is ok to ignore customBounds when schema is different.
When writing a Histogram, the unused fields should be cleared, e.g. in Copy.
For the arithmetic functions in FloatHistogram: only do the operation for custom histograms if it is a scalar and custom histogram or it's two custom histograms with the same bucket layout. For the case of custom histogram vs exponential histogram and custom histograms that have different layout issue a Jeanette's warning. (See #13494 .)
Checklist:
Update1: removed the need to store +Inf and direct interface to get the upper bounds as they can be accessed via the bucket iterators.
Proposal
In the model/histogram package, in the Histogram and FloatHistogram types add a slice called customBounds
Also add a constant to define the schema number that means custom buckets are in use. E.g. 127.
In general the schema number dictates the semantics of the operations. When reading / validating the data it is ok to ignore the negative spans/counts/deltas and zero bucket information if schema ==
CustomBucketsSchema. Conversely it is ok to ignorecustomBoundswhen schema is different.When writing a
Histogram, the unused fields should be cleared, e.g. in Copy.For the arithmetic functions in FloatHistogram: only do the operation for custom histograms if it is a scalar and custom histogram or it's two custom histograms with the same bucket layout. For the case of custom histogram vs exponential histogram and custom histograms that have different layout issue a Jeanette's warning. (See #13494 .)
Checklist:
Update1: removed the need to store +Inf and direct interface to get the upper bounds as they can be accessed via the bucket iterators.