Skip to content

Avoid a clone when creating PrimitiveArray from ArrayData - #9190

Merged
Dandandan merged 2 commits into
apache:mainfrom
alamb:alamb/primitive_array
Jan 15, 2026
Merged

Dandandan merged 2 commits into
apache:mainfrom
alamb:alamb/primitive_array

Conversation

@alamb

@alamb alamb commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Let's make arrow-rs the fastest we can and the fewer allocations the better

What changes are included in this PR?

Apply pattern from #9114

Are these changes tested?

Existing tests

Are there any user-facing changes?

No

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jan 15, 2026
data_type: data.data_type().clone(),
data_type,
values,
nulls: data.nulls().cloned(),

@alamb alamb Jan 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This saves a clone /call to DataType::drop as well as a Clone of Buffer (which is fairly inexpensive).

I don't think it will make any different in performance, but the code is cleaner and now consistent with other array types so I think this change is worth making

@albertlockett albertlockett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good @alamb

@rluvaton rluvaton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Dandandan
Dandandan merged commit 1035781 into apache:main Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants