mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-05-09 17:07:49 +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
|
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{
|
rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{
|
||||||
Name: name,
|
Name: name,
|
||||||
Type: scalarType,
|
Type: scalarType,
|
||||||
@ -39,7 +39,7 @@ func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type)
|
|||||||
return rtb
|
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{
|
rtb.recordType.Fields = append(rtb.recordType.Fields, &schema_pb.Field{
|
||||||
Name: name,
|
Name: name,
|
||||||
Type: &schema_pb.Type{Kind: &schema_pb.Type_RecordType{RecordType: recordType}},
|
Type: &schema_pb.Type{Kind: &schema_pb.Type_RecordType{RecordType: recordType}},
|
||||||
|
@ -31,8 +31,8 @@ func TestStructToSchema(t *testing.T) {
|
|||||||
}{},
|
}{},
|
||||||
},
|
},
|
||||||
want: RecordTypeBegin().
|
want: RecordTypeBegin().
|
||||||
SetField("Field1", TypeInteger).
|
WithField("Field1", TypeInteger).
|
||||||
SetField("Field2", TypeString).
|
WithField("Field2", TypeString).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -44,8 +44,8 @@ func TestStructToSchema(t *testing.T) {
|
|||||||
}{},
|
}{},
|
||||||
},
|
},
|
||||||
want: RecordTypeBegin().
|
want: RecordTypeBegin().
|
||||||
SetField("Field1", ListOf(TypeInteger)).
|
WithField("Field1", ListOf(TypeInteger)).
|
||||||
SetField("Field2", TypeString).
|
WithField("Field2", TypeString).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ func TestStructToSchema(t *testing.T) {
|
|||||||
}{},
|
}{},
|
||||||
},
|
},
|
||||||
want: RecordTypeBegin().
|
want: RecordTypeBegin().
|
||||||
SetField("Field2", TypeBytes).
|
WithField("Field2", TypeBytes).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -71,11 +71,11 @@ func TestStructToSchema(t *testing.T) {
|
|||||||
}{},
|
}{},
|
||||||
},
|
},
|
||||||
want: RecordTypeBegin().
|
want: RecordTypeBegin().
|
||||||
SetField("Field1", TypeInteger).
|
WithField("Field1", TypeInteger).
|
||||||
SetRecordField("Field2",
|
WithRecordField("Field2",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("Field3", TypeString).
|
WithField("Field3", TypeString).
|
||||||
SetField("Field4", TypeInteger).
|
WithField("Field4", TypeInteger).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
).
|
).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
@ -96,14 +96,14 @@ func TestStructToSchema(t *testing.T) {
|
|||||||
}{},
|
}{},
|
||||||
},
|
},
|
||||||
want: RecordTypeBegin().
|
want: RecordTypeBegin().
|
||||||
SetField("Field1", TypeInteger).
|
WithField("Field1", TypeInteger).
|
||||||
SetRecordField("Field2", RecordTypeBegin().
|
WithRecordField("Field2", RecordTypeBegin().
|
||||||
SetField("Field3", TypeString).
|
WithField("Field3", TypeString).
|
||||||
SetField("Field4", ListOf(TypeInteger)).
|
WithField("Field4", ListOf(TypeInteger)).
|
||||||
SetRecordField("Field5",
|
WithRecordField("Field5",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("Field6", TypeString).
|
WithField("Field6", TypeString).
|
||||||
SetField("Field7", TypeBytes).
|
WithField("Field7", TypeBytes).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
).RecordTypeEnd(),
|
).RecordTypeEnd(),
|
||||||
).
|
).
|
||||||
|
@ -19,18 +19,18 @@ func TestToParquetLevels(t *testing.T) {
|
|||||||
name: "nested type",
|
name: "nested type",
|
||||||
args: args{
|
args: args{
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("ID", TypeLong).
|
WithField("ID", TypeLong).
|
||||||
SetField("CreatedAt", TypeLong).
|
WithField("CreatedAt", TypeLong).
|
||||||
SetRecordField("Person",
|
WithRecordField("Person",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("zName", TypeString).
|
WithField("zName", TypeString).
|
||||||
SetField("emails", ListOf(TypeString)).
|
WithField("emails", ListOf(TypeString)).
|
||||||
RecordTypeEnd()).
|
RecordTypeEnd()).
|
||||||
SetField("Company", TypeString).
|
WithField("Company", TypeString).
|
||||||
SetRecordField("Address",
|
WithRecordField("Address",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("Street", TypeString).
|
WithField("Street", TypeString).
|
||||||
SetField("City", TypeString).
|
WithField("City", TypeString).
|
||||||
RecordTypeEnd()).
|
RecordTypeEnd()).
|
||||||
RecordTypeEnd(),
|
RecordTypeEnd(),
|
||||||
},
|
},
|
||||||
|
@ -13,18 +13,18 @@ import (
|
|||||||
func TestWriteReadParquet(t *testing.T) {
|
func TestWriteReadParquet(t *testing.T) {
|
||||||
// create a schema_pb.RecordType
|
// create a schema_pb.RecordType
|
||||||
recordType := RecordTypeBegin().
|
recordType := RecordTypeBegin().
|
||||||
SetField("ID", TypeLong).
|
WithField("ID", TypeLong).
|
||||||
SetField("CreatedAt", TypeLong).
|
WithField("CreatedAt", TypeLong).
|
||||||
SetRecordField("Person",
|
WithRecordField("Person",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("zName", TypeString).
|
WithField("zName", TypeString).
|
||||||
SetField("emails", ListOf(TypeString)).
|
WithField("emails", ListOf(TypeString)).
|
||||||
RecordTypeEnd()).
|
RecordTypeEnd()).
|
||||||
SetField("Company", TypeString).
|
WithField("Company", TypeString).
|
||||||
SetRecordField("Address",
|
WithRecordField("Address",
|
||||||
RecordTypeBegin().
|
RecordTypeBegin().
|
||||||
SetField("Street", TypeString).
|
WithField("Street", TypeString).
|
||||||
SetField("City", TypeString).
|
WithField("City", TypeString).
|
||||||
RecordTypeEnd()).
|
RecordTypeEnd()).
|
||||||
RecordTypeEnd()
|
RecordTypeEnd()
|
||||||
fmt.Printf("RecordType: %v\n", recordType)
|
fmt.Printf("RecordType: %v\n", recordType)
|
||||||
|
Loading…
Reference in New Issue
Block a user