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


##########
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:
   @tustvold I have a doubt about the `with_capacity` method. It takes two 
parameters: capacity of items and capacity of data (bytes). We can't compute 
data capacity without iterating (hence consuming elements) and cloning it could 
be costly. 
   
   Can we have some default value for the data capacity parameter? And if yes, 
what should it be?
   
   It applies to both `GenericStringBuilder` and `GenericBinaryBuilder`.



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