yevgenypats commented on code in PR #35307:
URL: https://github.com/apache/arrow/pull/35307#discussion_r1175764172
##########
go/arrow/schema.go:
##########
@@ -194,7 +194,11 @@ func (sc *Schema) WithEndianness(e endian.Endianness)
*Schema {
func (sc *Schema) Endianness() endian.Endianness { return sc.endianness }
func (sc *Schema) IsNativeEndian() bool { return sc.endianness ==
endian.NativeEndian }
func (sc *Schema) Metadata() Metadata { return sc.meta }
-func (sc *Schema) Fields() []Field { return sc.fields }
+func (sc *Schema) Fields() []Field {
+ fields := make([]Field, len(sc.fields))
+ copy(fields, sc.fields)
+ return fields
+}
Review Comment:
We can do that but currently all methods return copy of things - like
`Metadata` for example and `Field(i)` apart from this one (which also bit me in
our code as I wasn't expecting the returned value to change the internal state)
##########
go/arrow/schema.go:
##########
@@ -194,7 +194,11 @@ func (sc *Schema) WithEndianness(e endian.Endianness)
*Schema {
func (sc *Schema) Endianness() endian.Endianness { return sc.endianness }
func (sc *Schema) IsNativeEndian() bool { return sc.endianness ==
endian.NativeEndian }
func (sc *Schema) Metadata() Metadata { return sc.meta }
-func (sc *Schema) Fields() []Field { return sc.fields }
+func (sc *Schema) Fields() []Field {
+ fields := make([]Field, len(sc.fields))
+ copy(fields, sc.fields)
+ return fields
+}
Review Comment:
We can do that but currently all methods return copy of things - like
`Metadata` for example and `Field(i)` apart from this one (which also bitten me
in our code as I wasn't expecting the returned value to change the internal
state)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]