Jefffrey commented on code in PR #9292:
URL: https://github.com/apache/arrow-rs/pull/9292#discussion_r2736158003
##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -402,7 +395,10 @@ impl<T: ArrowNativeType> Extend<T> for BufferBuilder<T> {
impl<T: ArrowNativeType> From<Vec<T>> for BufferBuilder<T> {
fn from(value: Vec<T>) -> Self {
- Self::new_from_buffer(MutableBuffer::from(value))
+ let buffer = MutableBuffer::from(value);
+ // SAFETY
+ // - buffer is aligned to T
+ unsafe { Self::new_from_buffer(buffer) }
Review Comment:
This is the only usage of this API in our codebase, which already upholds
the invariants
##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -95,7 +94,11 @@ impl<T: ArrowNativeType> BufferBuilder<T> {
}
/// Creates a new builder from a [`MutableBuffer`]
- pub fn new_from_buffer(buffer: MutableBuffer) -> Self {
+ ///
+ /// # Safety
+ ///
+ /// - `buffer` bytes must be aligned to type `T`
+ pub unsafe fn new_from_buffer(buffer: MutableBuffer) -> Self {
Review Comment:
Main change here
##########
arrow-buffer/src/builder/mod.rs:
##########
@@ -231,12 +228,12 @@ impl<T: ArrowNativeType> BufferBuilder<T> {
///
/// ```
/// # use arrow_buffer::builder::BufferBuilder;
- ///
/// let mut builder = BufferBuilder::<u32>::new(10);
/// builder.append_n_zeroed(3);
///
/// assert_eq!(builder.len(), 3);
/// assert_eq!(builder.as_slice(), &[0, 0, 0])
+ /// ```
Review Comment:
Drive by cleanup of these empty lines in the docstring, see how they
currently look like:
<img width="1022" height="436" alt="Image"
src="https://github.com/user-attachments/assets/8684fc87-7040-49ac-84b9-8d4f9e0149e2"
/>
Also fix missing closing block syntax here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]