Skip to content

feat: Prevent UnionArray with Repeated Type IDs#4070

Merged
tustvold merged 5 commits intoapache:masterfrom
Weijun-H:prevent-union-array-with-repeated-type-id
Apr 12, 2023
Merged

feat: Prevent UnionArray with Repeated Type IDs#4070
tustvold merged 5 commits intoapache:masterfrom
Weijun-H:prevent-union-array-with-repeated-type-id

Conversation

@Weijun-H
Copy link
Member

Which issue does this PR close?

Closes #3982

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 12, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just use bit operations on a u128? It should both be faster and avoid a dependency.

Something like (not tested)

let mut set = 0_u128;

...

let mask = 1_u128 << idx
if (set & mask) != 0 {
    Err...
else {
    set |= mask
}

@Weijun-H Weijun-H force-pushed the prevent-union-array-with-repeated-type-id branch from a63c2fd to bc17da6 Compare April 12, 2023 19:08
@tustvold
Copy link
Contributor

Thank you, I think all this now needs is a test


#[test]
fn test_union_with_duplicated_type_id() {
std::panic::set_hook(Box::new(|_info| {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use should_panic for this, there should be examples you can crib from around the codebase

Copy link
Contributor

@tustvold tustvold 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

@tustvold tustvold merged commit f14a678 into apache:master Apr 12, 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.

Prevent UnionArray with Repeated Type IDs

2 participants