From 6af2f7bc18dccc8a68355d93f459c568d4055d44 Mon Sep 17 00:00:00 2001 From: ugol Date: Wed, 4 Oct 2023 17:02:35 +0200 Subject: [PATCH] small fixes --- pkg/types/shoe.avsc | 4 ++-- pkg/types/shoe.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/types/shoe.avsc b/pkg/types/shoe.avsc index 88a3364a..93e040e3 100644 --- a/pkg/types/shoe.avsc +++ b/pkg/types/shoe.avsc @@ -4,9 +4,9 @@ "name" : "shoe", "fields" : [ { "name" : "id" , "type" : "string"}, - { "name" : "sale_price" , "type" : "int" }, + { "name" : "sale_price" , "type" : "string" }, { "name" : "brand" , "type" : "string" }, { "name" : "name" , "type" : "string" }, - { "name" : "rating" , "type" : "float" } + { "name" : "rating" , "type" : "string" } ] } \ No newline at end of file diff --git a/pkg/types/shoe.go b/pkg/types/shoe.go index 89b330d5..9fbe14f7 100644 --- a/pkg/types/shoe.go +++ b/pkg/types/shoe.go @@ -59,16 +59,16 @@ var _ = fmt.Printf type Shoe struct { Id string `json:"id"` - Sale_price int32 `json:"sale_price"` + Sale_price string `json:"sale_price"` Brand string `json:"brand"` Name string `json:"name"` - Rating float32 `json:"rating"` + Rating string `json:"rating"` } -const ShoeAvroCRC64Fingerprint = "\xcee\a\x83]\xae\xc0\xda" +const ShoeAvroCRC64Fingerprint = "oB\xcd\xe9\x7f\xc7,\xd6" func NewShoe() Shoe { r := Shoe{} @@ -104,7 +104,7 @@ func writeShoe(r Shoe, w io.Writer) error { if err != nil { return err } - err = vm.WriteInt(r.Sale_price, w) + err = vm.WriteString(r.Sale_price, w) if err != nil { return err } @@ -116,7 +116,7 @@ func writeShoe(r Shoe, w io.Writer) error { if err != nil { return err } - err = vm.WriteFloat(r.Rating, w) + err = vm.WriteString(r.Rating, w) if err != nil { return err } @@ -128,7 +128,7 @@ func (r Shoe) Serialize(w io.Writer) error { } func (r Shoe) Schema() string { - return "{\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"sale_price\",\"type\":\"int\"},{\"name\":\"brand\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"rating\",\"type\":\"float\"}],\"name\":\"shoes.shoe\",\"type\":\"record\"}" + return "{\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"sale_price\",\"type\":\"string\"},{\"name\":\"brand\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"rating\",\"type\":\"string\"}],\"name\":\"shoes.shoe\",\"type\":\"record\"}" } func (r Shoe) SchemaName() string { @@ -152,7 +152,7 @@ func (r *Shoe) Get(i int) types.Field { return w case 1: - w := types.Int{Target: &r.Sale_price} + w := types.String{Target: &r.Sale_price} return w @@ -167,7 +167,7 @@ func (r *Shoe) Get(i int) types.Field { return w case 4: - w := types.Float{Target: &r.Rating} + w := types.String{Target: &r.Rating} return w