tustvold commented on code in PR #2038:
URL: https://github.com/apache/arrow-rs/pull/2038#discussion_r919157969


##########
arrow/src/array/builder/generic_binary_builder.rs:
##########
@@ -93,20 +108,33 @@ impl<OffsetSize: OffsetSizeTrait> ArrayBuilder for 
GenericBinaryBuilder<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 {
-        Arc::new(self.finish())
+impl<Ptr, OffsetSize: OffsetSizeTrait> FromIterator<Option<Ptr>>
+    for GenericBinaryBuilder<OffsetSize>
+where
+    Ptr: AsRef<[u8]>,
+{
+    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 = GenericBinaryBuilder::new(size_hint);

Review Comment:
   We likely want to use a `GenericBinaryBuilder::with_capacity` (which doesn't 
currently exist) here, to avoid this being a performance regression



-- 
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]

Reply via email to