-
Notifications
You must be signed in to change notification settings - Fork 841
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 typed buffers to UnionArray (#3880) #3933
Conversation
if self.is_dense() { | ||
self.data().buffers()[1].typed_data::<i32>()[self.offset() + index] | ||
} else { | ||
(self.offset() + index) as i32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can potentially overflow, so I opted to change value_offset to return usize as this is not only more correct, but is what most call-sites want anyway
I'll review this today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. It is also more clear for UnionArray struct itself.
for (i, id) in expected_type_ids.iter().enumerate() { | ||
assert_eq!(id, &array.type_id(i)); | ||
} | ||
|
||
// Check offsets, sparse union should only have a single buffer, i.e. no offsets | ||
assert_eq!(array.data().buffers().len(), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Co-authored-by: Liang-Chi Hsieh <[email protected]>
Which issue does this PR close?
Part of #3880
Rationale for this change
It currently isn't possible to interact with a UnionArray's buffers in a type-safe way. This is at odds with the other array types, and causes issues migrating away from storing ArrayData under arrays.
What changes are included in this PR?
Are there any user-facing changes?
This changes the return type of UnionArray::value_offset to be correct