Browse Source

rename api

mq-subscribe
chrislu 8 months ago
parent
commit
1a2332c257
  1. 14
      weed/mq/schema/schema_builder.go
  2. 4
      weed/mq/schema/struct_to_schema_test.go
  3. 14
      weed/mq/schema/to_parquet_levels_test.go

14
weed/mq/schema/schema_builder.go

@ -39,24 +39,12 @@ func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type)
return rtb
}
func (rtb *RecordTypeBuilder) SetBoolField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeBoolean)
}
func (rtb *RecordTypeBuilder) SetIntegerField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeInteger)
}
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) SetDoubleField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeDouble)
}
func (rtb *RecordTypeBuilder) SetBytesField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeBytes)
}
func (rtb *RecordTypeBuilder) SetStringField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeString)
}
@ -77,6 +65,6 @@ func (rtb *RecordTypeBuilder) SetListField(name string, elementType *schema_pb.T
return rtb
}
func List(elementType *schema_pb.Type) *schema_pb.Type {
func ListOf(elementType *schema_pb.Type) *schema_pb.Type {
return &schema_pb.Type{Kind: &schema_pb.Type_ListType{ListType: &schema_pb.ListType{ElementType: elementType}}}
}

4
weed/mq/schema/struct_to_schema_test.go

@ -44,7 +44,7 @@ func TestStructToSchema(t *testing.T) {
}{},
},
want: NewRecordTypeBuilder().
SetField("Field1", List(TypeInteger)).
SetField("Field1", ListOf(TypeInteger)).
SetField("Field2", TypeString).
Build(),
},
@ -97,7 +97,7 @@ func TestStructToSchema(t *testing.T) {
SetField("Field1", TypeInteger).
SetRecordField("Field2", NewRecordTypeBuilder().
SetField("Field3", TypeString).
SetField("Field4", List(TypeInteger)).
SetField("Field4", ListOf(TypeInteger)).
SetRecordField("Field5", NewRecordTypeBuilder().
SetField("Field6", TypeString).
SetField("Field7", TypeBytes),

14
weed/mq/schema/to_parquet_levels_test.go

@ -19,15 +19,15 @@ func TestToParquetLevels(t *testing.T) {
name: "nested type",
args: args{
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(),
},
want: &ParquetLevels{
startColumnIndex: 0,

Loading…
Cancel
Save