1
1
mirror of https://github.com/wader/fq.git synced 2024-12-01 02:30:32 +03:00
fq/format/avro/decoders/float.go

15 lines
425 B
Go
Raw Normal View History

2021-12-30 01:12:36 +03:00
package decoders
import (
"github.com/wader/fq/pkg/decode"
2022-01-14 08:32:19 +03:00
"github.com/wader/fq/pkg/scalar"
2021-12-30 01:12:36 +03:00
)
2022-01-20 08:53:33 +03:00
func decodeFloatFn(sms ...scalar.Mapper) (DecodeFn, error) {
2022-01-14 08:32:19 +03:00
// A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's
// floatToIntBits and then encoded in little-endian format.
return func(name string, d *decode.D) any {
2022-01-20 08:53:33 +03:00
return d.FieldF32(name, sms...)
2021-12-30 01:12:36 +03:00
}, nil
}