From 0da1b7b0f92021d1fd1a7a122ca042a218db0487 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 28 Apr 2024 12:42:58 -0700 Subject: [PATCH] improve api --- weed/mq/schema/schema_builder.go | 18 ------------------ weed/mq/schema/write_parquet_test.go | 14 +++++++------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/weed/mq/schema/schema_builder.go b/weed/mq/schema/schema_builder.go index 0bd324fb3..449820ecb 100644 --- a/weed/mq/schema/schema_builder.go +++ b/weed/mq/schema/schema_builder.go @@ -39,16 +39,6 @@ func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type) return rtb } -func (rtb *RecordTypeBuilder) SetLongField(name string) *RecordTypeBuilder { - return rtb.SetField(name, TypeLong) -} -func (rtb *RecordTypeBuilder) SetFloatField(name string) *RecordTypeBuilder { - return rtb.SetField(name, TypeFloat) -} -func (rtb *RecordTypeBuilder) SetStringField(name string) *RecordTypeBuilder { - return rtb.SetField(name, TypeString) -} - func (rtb *RecordTypeBuilder) SetRecordField(name string, recordTypeBuilder *RecordTypeBuilder) *RecordTypeBuilder { rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{ Name: name, @@ -57,14 +47,6 @@ func (rtb *RecordTypeBuilder) SetRecordField(name string, recordTypeBuilder *Rec return rtb } -func (rtb *RecordTypeBuilder) SetListField(name string, elementType *schema_pb.Type) *RecordTypeBuilder { - rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{ - Name: name, - Type: &schema_pb.Type{Kind: &schema_pb.Type_ListType{ListType: &schema_pb.ListType{ElementType: elementType}}}, - }) - return rtb -} - func ListOf(elementType *schema_pb.Type) *schema_pb.Type { return &schema_pb.Type{Kind: &schema_pb.Type_ListType{ListType: &schema_pb.ListType{ElementType: elementType}}} } diff --git a/weed/mq/schema/write_parquet_test.go b/weed/mq/schema/write_parquet_test.go index b05572600..9402530a6 100644 --- a/weed/mq/schema/write_parquet_test.go +++ b/weed/mq/schema/write_parquet_test.go @@ -13,15 +13,15 @@ import ( func TestWriteReadParquet(t *testing.T) { // create a schema_pb.RecordType recordType := NewRecordTypeBuilder(). - SetLongField("ID"). - SetLongField("CreatedAt"). + SetField("ID", TypeLong). + SetField("CreatedAt", TypeLong). SetRecordField("Person", NewRecordTypeBuilder(). - SetStringField("zName"). - SetListField("emails", TypeString)). - SetStringField("Company"). + SetField("zName", TypeString). + SetField("emails", ListOf(TypeString))). + SetField("Company", TypeString). SetRecordField("Address", NewRecordTypeBuilder(). - SetStringField("Street"). - SetStringField("City")).Build() + SetField("Street", TypeString). + SetField("City", TypeString)).Build() fmt.Printf("RecordType: %v\n", recordType) // create a parquet schema