diff --git a/weed/mq/schema/schema_builder.go b/weed/mq/schema/schema_builder.go index 19229c419..06cc8641b 100644 --- a/weed/mq/schema/schema_builder.go +++ b/weed/mq/schema/schema_builder.go @@ -31,7 +31,7 @@ func (rtb *RecordTypeBuilder) RecordTypeEnd() *schema_pb.RecordType { return rtb.recordType } -func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type) *RecordTypeBuilder { +func (rtb *RecordTypeBuilder) WithField(name string, scalarType *schema_pb.Type) *RecordTypeBuilder { rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{ Name: name, Type: scalarType, @@ -39,7 +39,7 @@ func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type) return rtb } -func (rtb *RecordTypeBuilder) SetRecordField(name string, recordType *schema_pb.RecordType) *RecordTypeBuilder { +func (rtb *RecordTypeBuilder) WithRecordField(name string, recordType *schema_pb.RecordType) *RecordTypeBuilder { rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{ Name: name, Type: &schema_pb.Type{Kind: &schema_pb.Type_RecordType{RecordType: recordType}}, diff --git a/weed/mq/schema/struct_to_schema_test.go b/weed/mq/schema/struct_to_schema_test.go index 71f8215dc..749e367f8 100644 --- a/weed/mq/schema/struct_to_schema_test.go +++ b/weed/mq/schema/struct_to_schema_test.go @@ -31,8 +31,8 @@ func TestStructToSchema(t *testing.T) { }{}, }, want: RecordTypeBegin(). - SetField("Field1", TypeInteger). - SetField("Field2", TypeString). + WithField("Field1", TypeInteger). + WithField("Field2", TypeString). RecordTypeEnd(), }, { @@ -44,8 +44,8 @@ func TestStructToSchema(t *testing.T) { }{}, }, want: RecordTypeBegin(). - SetField("Field1", ListOf(TypeInteger)). - SetField("Field2", TypeString). + WithField("Field1", ListOf(TypeInteger)). + WithField("Field2", TypeString). RecordTypeEnd(), }, { @@ -56,7 +56,7 @@ func TestStructToSchema(t *testing.T) { }{}, }, want: RecordTypeBegin(). - SetField("Field2", TypeBytes). + WithField("Field2", TypeBytes). RecordTypeEnd(), }, { @@ -71,11 +71,11 @@ func TestStructToSchema(t *testing.T) { }{}, }, want: RecordTypeBegin(). - SetField("Field1", TypeInteger). - SetRecordField("Field2", + WithField("Field1", TypeInteger). + WithRecordField("Field2", RecordTypeBegin(). - SetField("Field3", TypeString). - SetField("Field4", TypeInteger). + WithField("Field3", TypeString). + WithField("Field4", TypeInteger). RecordTypeEnd(), ). RecordTypeEnd(), @@ -96,14 +96,14 @@ func TestStructToSchema(t *testing.T) { }{}, }, want: RecordTypeBegin(). - SetField("Field1", TypeInteger). - SetRecordField("Field2", RecordTypeBegin(). - SetField("Field3", TypeString). - SetField("Field4", ListOf(TypeInteger)). - SetRecordField("Field5", + WithField("Field1", TypeInteger). + WithRecordField("Field2", RecordTypeBegin(). + WithField("Field3", TypeString). + WithField("Field4", ListOf(TypeInteger)). + WithRecordField("Field5", RecordTypeBegin(). - SetField("Field6", TypeString). - SetField("Field7", TypeBytes). + WithField("Field6", TypeString). + WithField("Field7", TypeBytes). RecordTypeEnd(), ).RecordTypeEnd(), ). diff --git a/weed/mq/schema/to_parquet_levels_test.go b/weed/mq/schema/to_parquet_levels_test.go index 65a90f956..b75f6b721 100644 --- a/weed/mq/schema/to_parquet_levels_test.go +++ b/weed/mq/schema/to_parquet_levels_test.go @@ -19,18 +19,18 @@ func TestToParquetLevels(t *testing.T) { name: "nested type", args: args{ RecordTypeBegin(). - SetField("ID", TypeLong). - SetField("CreatedAt", TypeLong). - SetRecordField("Person", + WithField("ID", TypeLong). + WithField("CreatedAt", TypeLong). + WithRecordField("Person", RecordTypeBegin(). - SetField("zName", TypeString). - SetField("emails", ListOf(TypeString)). + WithField("zName", TypeString). + WithField("emails", ListOf(TypeString)). RecordTypeEnd()). - SetField("Company", TypeString). - SetRecordField("Address", + WithField("Company", TypeString). + WithRecordField("Address", RecordTypeBegin(). - SetField("Street", TypeString). - SetField("City", TypeString). + WithField("Street", TypeString). + WithField("City", TypeString). RecordTypeEnd()). RecordTypeEnd(), }, diff --git a/weed/mq/schema/write_parquet_test.go b/weed/mq/schema/write_parquet_test.go index 19576cfdd..013361ff2 100644 --- a/weed/mq/schema/write_parquet_test.go +++ b/weed/mq/schema/write_parquet_test.go @@ -13,18 +13,18 @@ import ( func TestWriteReadParquet(t *testing.T) { // create a schema_pb.RecordType recordType := RecordTypeBegin(). - SetField("ID", TypeLong). - SetField("CreatedAt", TypeLong). - SetRecordField("Person", + WithField("ID", TypeLong). + WithField("CreatedAt", TypeLong). + WithRecordField("Person", RecordTypeBegin(). - SetField("zName", TypeString). - SetField("emails", ListOf(TypeString)). + WithField("zName", TypeString). + WithField("emails", ListOf(TypeString)). RecordTypeEnd()). - SetField("Company", TypeString). - SetRecordField("Address", + WithField("Company", TypeString). + WithRecordField("Address", RecordTypeBegin(). - SetField("Street", TypeString). - SetField("City", TypeString). + WithField("Street", TypeString). + WithField("City", TypeString). RecordTypeEnd()). RecordTypeEnd() fmt.Printf("RecordType: %v\n", recordType)