Skip to content

GH-35866: [Go] Provide a copy in arrow.NestedType.Fields() implementations#35867

Merged
zeroshade merged 3 commits intoapache:mainfrom
cloudquery:fix/struct-fields-mutable
Jun 1, 2023
Merged

GH-35866: [Go] Provide a copy in arrow.NestedType.Fields() implementations#35867
zeroshade merged 3 commits intoapache:mainfrom
cloudquery:fix/struct-fields-mutable

Conversation

@candiduslynx
Copy link
Copy Markdown
Contributor

@candiduslynx candiduslynx commented Jun 1, 2023

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.TestFieldsImmutability was added to ensure the behavior.

Are there any user-facing changes?

Now the fields for structs & unions will be immutable.

@candiduslynx candiduslynx requested a review from zeroshade as a code owner June 1, 2023 08:52
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 1, 2023

⚠️ GitHub issue #35866 has been automatically assigned in GitHub to PR creator.

kodiakhq bot pushed a commit to cloudquery/filetypes that referenced this pull request Jun 1, 2023
#172)

Extracted from #171

Structs reading is slow because of apache/arrow#35851
Fields copy is because of apache/arrow#35867
Copy link
Copy Markdown
Member

@zeroshade zeroshade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jun 1, 2023
@candiduslynx
Copy link
Copy Markdown
Contributor Author

candiduslynx commented Jun 1, 2023

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, Field(i) provides a copy of the arrow.Field (note: the Type field will point to the same instance, but the pointer itself is copied).

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jun 1, 2023
@candiduslynx candiduslynx requested a review from zeroshade June 1, 2023 15:37
@zeroshade
Copy link
Copy Markdown
Member

@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.

@zeroshade zeroshade merged commit e0fd7ef into apache:main Jun 1, 2023
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Jun 1, 2023
@candiduslynx candiduslynx deleted the fix/struct-fields-mutable branch June 1, 2023 19:49
kodiakhq bot pushed a commit to cloudquery/filetypes that referenced this pull request Jun 1, 2023
@ursabot
Copy link
Copy Markdown

ursabot commented Jun 2, 2023

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.
Conbench compare runs links:
[Finished ⬇️25.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.83% ⬆️0.0%] test-mac-arm
[Finished ⬇️1.63% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.39% ⬆️0.03%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] e0fd7ef8 ec2-t3-xlarge-us-east-2
[Finished] e0fd7ef8 test-mac-arm
[Finished] e0fd7ef8 ursa-i9-9960x
[Finished] e0fd7ef8 ursa-thinkcentre-m75q
[Finished] c67fb399 ec2-t3-xlarge-us-east-2
[Failed] c67fb399 test-mac-arm
[Finished] c67fb399 ursa-i9-9960x
[Finished] c67fb399 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] arrow.StructType fields are mutable

3 participants