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 ScalarBuffer abstraction (#1811) #1820

Merged
merged 2 commits into from
Jun 9, 2022

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Jun 8, 2022

Which issue does this PR close?

Part of #1811

Rationale for this change

This would allow replacing RawPtrBox with a safe abstraction

What changes are included in this PR?

This adds a new owning ScalarBuffer abstraction that wraps a Buffer in an owning abstraction

Are there any user-facing changes?

No

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 8, 2022
@tustvold tustvold marked this pull request as ready for review June 8, 2022 15:03
/// All [`ArrowNativeType`] are valid for all possible backing byte representations, and as
/// a result they are "trivially safely transmutable".
#[derive(Debug)]
pub struct ScalarBuffer<T: ArrowNativeType> {
Copy link
Member

Choose a reason for hiding this comment

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

Is this to be public to users? If this is only for used internally in Array implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We definitely could make it crate local, I think a ScalarMutableBuffer would be of great interest to parquet, and so I was just thinking we'd provide public safe APIs for interacting with buffers. Don't feel strongly

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

Looks promising. 👍

@tustvold tustvold merged commit 8f1fd12 into apache:master Jun 9, 2022
use crate::datatypes::ArrowNativeType;
use std::ops::Deref;

/// Provides a safe API for interpreting a [`Buffer`] as a slice of [`ArrowNativeType`]
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I right in understanding that the key use of this API will be to check the validity of buffer once and subsequently "just access" it rather than having to do the checks subsequently (or skip them entirely)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Precisely - see #1825 for how this works in practice

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.

None yet

3 participants