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


##########
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:
   Looking at the original code, it uses a values capacity of 0 bytes - 
https://github.com/apache/arrow-rs/pull/2038/files#diff-d90c701e089ed03b4767c4c4ee8b7fe20410d22f98ea95313370a2c259550d3eL227
   
   It should therefore not represent a regression to just do the same. We can 
then revisit this in the context of #2054 



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