Dandandan commented on code in PR #9426:
URL: https://github.com/apache/arrow-rs/pull/9426#discussion_r2832229833
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -110,6 +110,19 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
self.offsets_builder.push(self.next_offset());
}
+ /// Appends a value of type `T` into the builder `n` times.
+ ///
+ /// See [`Self::append_value`] for more panic information.
+ #[inline]
+ pub fn append_value_n(&mut self, value: impl AsRef<T::Native>, n: usize) {
+ let bytes = value.as_ref().as_ref();
+ for _ in 0..n {
+ self.value_builder.extend_from_slice(bytes);
Review Comment:
As this is `append_value_n` I believe it makes sense to add a `reserve
here`.
While the builder provides `with_capacity` - the primary use case for using
a builder is when you don't know the capacity upfront (in most other cases you
can build the array from iterator or slice directly and skipping the builder
overhead).
##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -110,6 +110,19 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
self.offsets_builder.push(self.next_offset());
}
+ /// Appends a value of type `T` into the builder `n` times.
+ ///
+ /// See [`Self::append_value`] for more panic information.
+ #[inline]
+ pub fn append_value_n(&mut self, value: impl AsRef<T::Native>, n: usize) {
+ let bytes = value.as_ref().as_ref();
+ for _ in 0..n {
+ self.value_builder.extend_from_slice(bytes);
Review Comment:
As this is `append_value_n` I believe it makes sense to add a `reserve`.
While the builder provides `with_capacity` - the primary use case for using
a builder is when you don't know the capacity upfront (in most other cases you
can build the array from iterator or slice directly and skipping the builder
overhead).
--
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]