mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
rename to WithField()
This commit is contained in:
parent
a568d128fb
commit
5bc1b70a4c
@ -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}},
|
||||
|
@ -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(),
|
||||
).
|
||||
|
@ -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(),
|
||||
},
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user