Skip to content

Add an API to append view by u128 in for view_builder #6291

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions arrow-array/src/builder/generic_bytes_view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
self.null_buffer_builder.append_non_null();
}

/// Append the given `u128` as a view
///
/// # Safety
/// (1) The block of the given view must have been added
/// (2) The range `offset...offset+length` of the given view
/// must be within the bounds of the block
/// (3) The data in the block must be valid type `T`
/// (4) The view must be not null
pub unsafe fn append_view_u128_unchecked(&mut self, view: u128) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If appending raw u128 what is the benefit of using the builder at all, as opposed to just using a Vec<u128> directly? Is the intended use-case to intermix this method with some of the others?

Copy link
Contributor Author

@Kev1n8 Kev1n8 Aug 23, 2024

Choose a reason for hiding this comment

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

That's a good point. However, I believe that StringViewArray does not currently provide a From<Vec<u128>> trait directly. The related PR is intended to manually modify views to obtain the substr_view, which can then be added to the builder. Additionally, since the core implementation of StringView is based on the builder pattern, it seemed natural to me to use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

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 see. That's useful. Thanks.

self.views_builder.append(view);
self.null_buffer_builder.append_non_null();
}

/// Try to append a view of the given `block`, `offset` and `length`
///
/// See [`Self::append_block`]
Expand Down
Loading