mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 15:44:05 -08:00
Merge pull request #890 from prometheus/fix-float-conversions
storage: Fix float->uint conversions on some compilers.
This commit is contained in:
commit
1c25247a75
|
@ -156,11 +156,11 @@ func (c deltaEncodedChunk) add(s *metric.SamplePair) []chunk {
|
|||
case d0:
|
||||
// No-op. Constant value is stored as base value.
|
||||
case d1:
|
||||
c[offset] = byte(dv)
|
||||
c[offset] = byte(int8(dv))
|
||||
case d2:
|
||||
binary.LittleEndian.PutUint16(c[offset:], uint16(dv))
|
||||
binary.LittleEndian.PutUint16(c[offset:], uint16(int16(dv)))
|
||||
case d4:
|
||||
binary.LittleEndian.PutUint32(c[offset:], uint32(dv))
|
||||
binary.LittleEndian.PutUint32(c[offset:], uint32(int32(dv)))
|
||||
// d8 must not happen. Those samples are encoded as float64.
|
||||
default:
|
||||
panic("invalid number of bytes for integer delta")
|
||||
|
|
|
@ -164,11 +164,11 @@ func (c doubleDeltaEncodedChunk) add(s *metric.SamplePair) []chunk {
|
|||
case d0:
|
||||
// No-op. Constant delta is stored as base value.
|
||||
case d1:
|
||||
c[offset] = byte(ddv)
|
||||
c[offset] = byte(int8(ddv))
|
||||
case d2:
|
||||
binary.LittleEndian.PutUint16(c[offset:], uint16(ddv))
|
||||
binary.LittleEndian.PutUint16(c[offset:], uint16(int16(ddv)))
|
||||
case d4:
|
||||
binary.LittleEndian.PutUint32(c[offset:], uint32(ddv))
|
||||
binary.LittleEndian.PutUint32(c[offset:], uint32(int32(ddv)))
|
||||
// d8 must not happen. Those samples are encoded as float64.
|
||||
default:
|
||||
panic("invalid number of bytes for integer delta")
|
||||
|
|
Loading…
Reference in a new issue