From ad9e630abfa16731a1f5c33faef87754193dc201 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 27 Apr 2023 09:22:40 +0300 Subject: [PATCH] chore: remove bfloat16.Map --- ch/bfloat16/bfloat16.go | 6 ++---- ch/chschema/column.go | 4 ++-- ch/chschema/types.go | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/ch/bfloat16/bfloat16.go b/ch/bfloat16/bfloat16.go index 1c57a27..dca22f4 100644 --- a/ch/bfloat16/bfloat16.go +++ b/ch/bfloat16/bfloat16.go @@ -4,15 +4,13 @@ import ( "math" ) -type Map map[T]uint64 - type T uint16 func From(f float64) T { - return FromFloat32(float32(f)) + return From32(float32(f)) } -func FromFloat32(f float32) T { +func From32(f float32) T { return T(math.Float32bits(f) >> 16) } diff --git a/ch/chschema/column.go b/ch/chschema/column.go index 2464c93..735540d 100644 --- a/ch/chschema/column.go +++ b/ch/chschema/column.go @@ -498,7 +498,7 @@ func (c *JSONColumn) WriteTo(wr *chproto.Writer) error { //------------------------------------------------------------------------------ type BFloat16HistColumn struct { - ColumnOf[bfloat16.Map] + ColumnOf[map[bfloat16.T]uint64] } var _ Columnar = (*BFloat16HistColumn)(nil) @@ -524,7 +524,7 @@ func (c *BFloat16HistColumn) ReadFrom(rd *chproto.Reader, numRow int) error { return err } - data := make(bfloat16.Map, n) + data := make(map[bfloat16.T]uint64, n) for j := 0; j < int(n); j++ { value, err := rd.UInt16() diff --git a/ch/chschema/types.go b/ch/chschema/types.go index 48519dd..f0e737b 100644 --- a/ch/chschema/types.go +++ b/ch/chschema/types.go @@ -32,7 +32,7 @@ var ( timeType = reflect.TypeOf((*time.Time)(nil)).Elem() ipType = reflect.TypeOf((*net.IP)(nil)).Elem() ipNetType = reflect.TypeOf((*net.IPNet)(nil)).Elem() - bfloat16MapType = reflect.TypeOf((*bfloat16.Map)(nil)).Elem() + bfloat16MapType = reflect.TypeOf((*map[bfloat16.T]uint64)(nil)).Elem() sliceUint64Type = reflect.TypeOf((*[]uint64)(nil)).Elem() sliceFloat32Type = reflect.TypeOf((*[]float32)(nil)).Elem() @@ -114,8 +114,6 @@ func ColumnFactory(chType string, typ reflect.Type) NewColumnFunc { case chtype.DateTime: return NewDateTimeColumn - case chtype.DateTime64: - return NewDateTime64Column case chtype.Date: return NewDateColumn