tustvold commented on a change in pull request #6980:
URL: https://github.com/apache/arrow/pull/6980#discussion_r412736972
##########
File path: rust/arrow/src/array/builder.rs
##########
@@ -236,6 +251,14 @@ impl<T: ArrowPrimitiveType> BufferBuilderTrait<T> for
BufferBuilder<T> {
self.write_bytes(v.to_byte_slice(), 1)
}
+ default fn append_n(&mut self, n: usize, v: T::Native) -> Result<()> {
+ self.reserve(n)?;
+ for _ in 0..n {
+ self.write_bytes(v.to_byte_slice(), 1)?;
+ }
Review comment:
That would be incorrect though? The method should write the value `v`
`n` times. Calling `write_bytes(v.to_byte_slice(), n)` would write `v` once and
then increase the recorded element count by n, which would leave things in an
odd state.
For the general case there is little reason for this method to exist, aside
from reserving memory once. It mainly exists because the bitmap specialization
can more efficiently append the same value multiple times than a naive loop
such as this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]