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

Add Array::to_data and Array::nulls (#3880) #3881

Merged
merged 5 commits into from
Mar 17, 2023

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Part of #3880

Rationale for this change

In order to be able to remove ArrayData from inside the various Array abstractions, we need to tweak the Array interface slightly

What changes are included in this PR?

Are there any user-facing changes?

This PR doesn't make any breaking changes, yet...

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 17, 2023
@@ -117,7 +117,7 @@ where
.map(|i| unsafe { array.value_unchecked(i) })
.reduce(|acc, item| if cmp(&acc, &item) { item } else { acc })
} else {
let nulls = array.data().nulls().unwrap();
let nulls = array.nulls().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

The point of this PR, as I understand it, is to remove direct use of data() -- so that eventually the Arrays themselves do not need to hold ArrayData but rather the strongly typed variants.

The plan is not to remove ArrayData completely, but rather construct it on demand if needed from the appropriate parts of each Array

fn data(&self) -> &ArrayData;

/// Returns the underlying data of this array.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think some docs explaining the (subtle) difference between to_data and into_data, and what the implications of using the two APIs are would be helpful here (like into_data doesn't increase the underlying ref count?

/// Returns the underlying data of this array.
fn into_data(self) -> ArrayData;

/// Returns a reference-counted pointer to the underlying data of this array.
///
/// 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.

Should we mark it as #[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.

I expect to do so in a future PR, trying to avoid changing all the things at once 😄

@tustvold tustvold merged commit 4e4a7f7 into apache:master Mar 17, 2023
spebern pushed a commit to spebern/arrow-rs that referenced this pull request Mar 25, 2023
* Add Array::to_data and Array::nulls (apache#3880)

* Review feedback

* Format
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