You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/01/15 13:12:34 UTC
[PR] Avoid a clone when creating `MapArray` from ArrayData [arrow-rs]
alamb opened a new pull request, #9192:
URL: https://github.com/apache/arrow-rs/pull/9192
# Which issue does this PR close?
- Part of https://github.com/apache/arrow-rs/issues/9061
- broken out of https://github.com/apache/arrow-rs/pull/9058
# 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 https://github.com/apache/arrow-rs/pull/9114
# Are these changes tested?
Existing tests
# Are there any user-facing changes?
No
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid a clone when creating `MapArray` from ArrayData [arrow-rs]
Posted by "jhorstmann (via GitHub)" <gi...@apache.org>.
jhorstmann commented on PR #9192:
URL: https://github.com/apache/arrow-rs/pull/9192#issuecomment-3763354385
Looks good (though I'm not too familiar with the layout of MapArray) 🚀
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid a clone when creating `MapArray` from ArrayData [arrow-rs]
Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan merged PR #9192:
URL: https://github.com/apache/arrow-rs/pull/9192
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Avoid a clone when creating `MapArray` from ArrayData [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9192:
URL: https://github.com/apache/arrow-rs/pull/9192#discussion_r2694414381
##########
arrow-array/src/array/map_array.rs:
##########
@@ -272,28 +272,29 @@ impl From<MapArray> for ArrayData {
impl MapArray {
fn try_new_from_array_data(data: ArrayData) -> Result<Self, ArrowError> {
- if !matches!(data.data_type(), DataType::Map(_, _)) {
+ let (data_type, len, nulls, offset, mut buffers, mut child_data) = data.into_parts();
+
+ if !matches!(data_type, DataType::Map(_, _)) {
return Err(ArrowError::InvalidArgumentError(format!(
- "MapArray expected ArrayData with DataType::Map got {}",
- data.data_type()
+ "MapArray expected ArrayData with DataType::Map got {data_type}",
)));
}
- if data.buffers().len() != 1 {
+ if buffers.len() != 1 {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray data should contain a single buffer only (value offsets), had {}",
- data.len()
+ buffers.len(),
)));
}
+ let buffer = buffers.pop().expect("checked above");
- if data.child_data().len() != 1 {
+ if child_data.len() != 1 {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray should contain a single child array (values array), had {}",
- data.child_data().len()
+ child_data.len()
)));
}
-
- let entries = data.child_data()[0].clone();
Review Comment:
Here is a clone of ArrayData that is now saved
##########
arrow-array/src/array/map_array.rs:
##########
@@ -272,28 +272,29 @@ impl From<MapArray> for ArrayData {
impl MapArray {
fn try_new_from_array_data(data: ArrayData) -> Result<Self, ArrowError> {
- if !matches!(data.data_type(), DataType::Map(_, _)) {
+ let (data_type, len, nulls, offset, mut buffers, mut child_data) = data.into_parts();
+
+ if !matches!(data_type, DataType::Map(_, _)) {
return Err(ArrowError::InvalidArgumentError(format!(
- "MapArray expected ArrayData with DataType::Map got {}",
- data.data_type()
+ "MapArray expected ArrayData with DataType::Map got {data_type}",
)));
}
- if data.buffers().len() != 1 {
+ if buffers.len() != 1 {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray data should contain a single buffer only (value offsets), had {}",
- data.len()
+ buffers.len(),
)));
}
+ let buffer = buffers.pop().expect("checked above");
- if data.child_data().len() != 1 {
+ if child_data.len() != 1 {
return Err(ArrowError::InvalidArgumentError(format!(
"MapArray should contain a single child array (values array), had {}",
- data.child_data().len()
+ child_data.len()
)));
}
-
- let entries = data.child_data()[0].clone();
Review Comment:
Here is a clone of ArrayData that is avoided
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org