Skip to content

Add const MAX_OFFSET to OffsetSizeTrait #7478

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

Merged
merged 1 commit into from
May 7, 2025

Conversation

thinkharderdev
Copy link
Contributor

Which issue does this PR close?

Closes #7474.

Rationale for this change

In native code it is useful to be able to write code generic over OffsetSizeTrait and it would be useful to know the max offset as a usize without deriving it at runtime

What changes are included in this PR?

add const MAX_OFFSET: usize to OffsetSizeTrait

Are there any user-facing changes?

No

No

@github-actions github-actions bot added the arrow Changes to the arrow crate label May 7, 2025
@thinkharderdev thinkharderdev merged commit ab45719 into apache:main May 7, 2025
26 checks passed
@alamb
Copy link
Contributor

alamb commented May 7, 2025

❤️

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @thinkharderdev and @Dandandan

}

impl OffsetSizeTrait for i32 {
const IS_LARGE: bool = false;
const PREFIX: &'static str = "";
const MAX_OFFSET: usize = i32::MAX as usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it would make sense to add this as u64 rather than usize so it works on 32 bit platforms like wasm

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.

Add a way to get max usize from OffsetSizeTrait
3 participants