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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]