Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Array::data (#3880) #4019

Merged
merged 2 commits into from
Apr 5, 2023
Merged

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Apr 4, 2023

Which issue does this PR close?

Part of #3880

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 4, 2023
@@ -111,6 +110,7 @@ pub trait Array: std::fmt::Debug + Send + Sync {
///
/// This will be deprecated in a future release [(#3880)](https://github.com/apache/arrow-rs/issues/3880)
#[deprecated(note = "Use Array::to_data or Array::into_data")]
#[allow(deprecated)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Part of #3880 will be to port these to not use Array::data

@@ -193,7 +193,8 @@ fn interleave_fallback(
values: &[&dyn Array],
indices: &[(usize, usize)],
) -> Result<ArrayRef, ArrowError> {
let arrays: Vec<_> = values.iter().map(|x| x.data()).collect();
let arrays: Vec<_> = values.iter().map(|x| x.to_data()).collect();
let arrays: Vec<_> = arrays.iter().collect();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is perhaps a little unfortunate, but given what this operation is doing, it is not going to be relevant to the benchmarks, the machinery of creating a MutableArrayData alone is likely more costly

Copy link
Contributor

Choose a reason for hiding this comment

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

We could potentially change the MutableArrayData constructor to take impl IntoIterator<Item = &'ArrayData> but that seems like it just moves the copy around.

@@ -467,9 +467,6 @@ mod tests {
let list_array = GenericListArray::<O>::from(array_data2);
let binary_array2 = GenericBinaryArray::<O>::from(list_array);

assert_eq!(2, binary_array2.data().buffers().len());
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is no longer needed because the ArrayData builder will check the buffer count (is that correct)?

@@ -4875,15 +4874,9 @@ mod tests {
assert_eq!(0, cast_array.null_count());

// offsets should be the same
assert_eq!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the equality comparison still covered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

List arrays only contain a single buffer, and so assert_eq!(list_array.value_offsets(), array.value_offsets()); is equivalent

@@ -81,7 +81,8 @@ pub fn concat(arrays: &[&dyn Array]) -> Result<ArrayRef, ArrowError> {
_ => Capacities::Array(arrays.iter().map(|a| a.len()).sum()),
};

let array_data = arrays.iter().map(|a| a.data()).collect::<Vec<_>>();
let array_data: Vec<_> = arrays.iter().map(|a| a.to_data()).collect::<Vec<_>>();
let array_data = array_data.iter().collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need the second iter/collect?

Update: Because it wants a Vec of &ArrayData

@@ -193,7 +193,8 @@ fn interleave_fallback(
values: &[&dyn Array],
indices: &[(usize, usize)],
) -> Result<ArrayRef, ArrowError> {
let arrays: Vec<_> = values.iter().map(|x| x.data()).collect();
let arrays: Vec<_> = values.iter().map(|x| x.to_data()).collect();
let arrays: Vec<_> = arrays.iter().collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

We could potentially change the MutableArrayData constructor to take impl IntoIterator<Item = &'ArrayData> but that seems like it just moves the copy around.

@@ -111,6 +110,7 @@ pub trait Array: std::fmt::Debug + Send + Sync {
///
/// This will be deprecated in a future release [(#3880)](https://github.com/apache/arrow-rs/issues/3880)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// This will be deprecated in a future release [(#3880)](https://github.com/apache/arrow-rs/issues/3880)
/// This will be removed in a future release [(#3880)](https://github.com/apache/arrow-rs/issues/3880)

@tustvold tustvold merged commit 39a48e1 into apache:master Apr 5, 2023
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.

3 participants