Encode zero threshold first

This guaranees that the zero threshold is byte-aligned. Not sure if
that helps in any way, but at least it won't harm.

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2021-10-14 14:55:21 +02:00
parent c5522677bf
commit 3179215a59

View file

@ -20,8 +20,8 @@ import (
) )
func writeHistogramChunkLayout(b *bstream, schema int32, zeroThreshold float64, positiveSpans, negativeSpans []histogram.Span) { func writeHistogramChunkLayout(b *bstream, schema int32, zeroThreshold float64, positiveSpans, negativeSpans []histogram.Span) {
putVarbitInt(b, int64(schema))
putZeroThreshold(b, zeroThreshold) putZeroThreshold(b, zeroThreshold)
putVarbitInt(b, int64(schema))
putHistogramChunkLayoutSpans(b, positiveSpans) putHistogramChunkLayoutSpans(b, positiveSpans)
putHistogramChunkLayoutSpans(b, negativeSpans) putHistogramChunkLayoutSpans(b, negativeSpans)
} }
@ -31,17 +31,17 @@ func readHistogramChunkLayout(b *bstreamReader) (
positiveSpans, negativeSpans []histogram.Span, positiveSpans, negativeSpans []histogram.Span,
err error, err error,
) { ) {
zeroThreshold, err = readZeroThreshold(b)
if err != nil {
return
}
v, err := readVarbitInt(b) v, err := readVarbitInt(b)
if err != nil { if err != nil {
return return
} }
schema = int32(v) schema = int32(v)
zeroThreshold, err = readZeroThreshold(b)
if err != nil {
return
}
positiveSpans, err = readHistogramChunkLayoutSpans(b) positiveSpans, err = readHistogramChunkLayoutSpans(b)
if err != nil { if err != nil {
return return