tustvold commented on code in PR #2038:
URL: https://github.com/apache/arrow-rs/pull/2038#discussion_r919156768
##########
arrow/src/array/builder/generic_string_builder.rs:
##########
@@ -114,21 +130,33 @@ impl<OffsetSize: OffsetSizeTrait> ArrayBuilder for
GenericStringBuilder<OffsetSi
fn into_box_any(self: Box<Self>) -> Box<dyn Any> {
self
}
+}
- /// Returns the number of array slots in the builder
- fn len(&self) -> usize {
- self.builder.len()
- }
-
- /// Returns whether the number of array slots is zero
- fn is_empty(&self) -> bool {
- self.builder.is_empty()
- }
-
- /// Builds the array and reset this builder.
- fn finish(&mut self) -> ArrayRef {
- let a = GenericStringBuilder::<OffsetSize>::finish(self);
- Arc::new(a)
+impl<Ptr, OffsetSize: OffsetSizeTrait> FromIterator<Option<Ptr>>
+ for GenericStringBuilder<OffsetSize>
+where
+ Ptr: AsRef<str>,
+{
+ fn from_iter<I: IntoIterator<Item = Option<Ptr>>>(iter: I) -> Self {
+ let iter = iter.into_iter();
+ let (lower, upper) = iter.size_hint();
+ let size_hint = upper.unwrap_or(lower);
+
+ let mut builder = GenericStringBuilder::new(size_hint);
Review Comment:
We probably want to use GenericStringBuilder::with_capacity 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]