GH-35866: [Go] Provide a copy in arrow.NestedType.Fields() implementations#35867
GH-35866: [Go] Provide a copy in arrow.NestedType.Fields() implementations#35867zeroshade merged 3 commits intoapache:mainfrom
arrow.NestedType.Fields() implementations#35867Conversation
|
|
#172) Extracted from #171 Structs reading is slow because of apache/arrow#35851 Fields copy is because of apache/arrow#35867
zeroshade
left a comment
There was a problem hiding this comment.
LGTM just want to have the documentation indicate that it makes a copy so that callers can choose to instead use the Field(i) methods if they want to avoid the copies
Just FYI, |
|
@candiduslynx true, (a mistake in my wording) i meant if they didn't want to make a copy of the entire slice of fields. Copying an individual field is extremely cheap, but under certain circumstances it could be desireable to avoid copying the entire slice of fields. Either way most times that a slice is returned from a method in go, the average usage assumes that it isn't making a copy of all the elements so it's good to ensure the godoc is clear. |
|
Benchmark runs are scheduled for baseline = c67fb39 and contender = e0fd7ef. e0fd7ef is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Rationale for this change
Data types should be left immutable after they've been constructed.
What changes are included in this PR?
Provide a copy of fields in the following implementations:
*arrow.StructType.Fields()*arrow.unionType.Fields()Are these changes tested?
arrow.TestFieldsImmutabilitywas added to ensure the behavior.Are there any user-facing changes?
Now the fields for structs & unions will be immutable.
arrow.StructTypefields are mutable #35866