yilin0518 commented on issue #9286: URL: https://github.com/apache/arrow-rs/issues/9286#issuecomment-3808720865
> I think root cause is that in truncate we set the length regardless of if it is smaller than current length or not: > > [arrow-rs/arrow-buffer/src/builder/mod.rs](https://github.com/apache/arrow-rs/blob/a49af1de8543b844430d799dff89d125a6f87221/arrow-buffer/src/builder/mod.rs#L310-L334) > > Lines 310 to 334 in [a49af1d](/apache/arrow-rs/commit/a49af1de8543b844430d799dff89d125a6f87221) > > /// Shorten this BufferBuilder to `len` items > /// > /// If `len` is greater than the builder's current length, this has no effect > /// > /// # Example: > /// > /// ``` > /// # use arrow_buffer::builder::BufferBuilder; > /// > /// let mut builder = BufferBuilder::<u16>::new(10); > /// > /// builder.append_slice(&[42, 44, 46]); > /// assert_eq!(builder.as_slice(), &[42, 44, 46]); > /// > /// builder.truncate(2); > /// assert_eq!(builder.as_slice(), &[42, 44]); > /// > /// builder.append(12); > /// assert_eq!(builder.as_slice(), &[42, 44, 12]); > /// ``` > #[inline] > pub fn truncate(&mut self, len: usize) { > self.buffer.truncate(len * std::mem::size_of::<T>()); > self.len = len; > } > * We state `If len is greater than builder's current length, this has no effect` > * But we still set length of builder to the passed in length It seems that it is right, as (151+219)*8 = 2960, so maybe it is a bug in this crate? -- 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]
