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


##########
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 should preserve the pre-existing behaviour of using a values capacity of 
0, and an offset capacity from the size hint. Otherwise this PR represents a 
non-trivial 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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to