You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/12 13:42:23 UTC

[GitHub] [arrow-rs] heyrutvik commented on a diff in pull request #2038: Implement FromIterator for Builders

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


##########
arrow/src/array/builder/decimal_builder.rs:
##########
@@ -149,20 +167,39 @@ impl ArrayBuilder for DecimalBuilder {
     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()
-    }
+impl<Ptr: Borrow<Option<i128>>> FromIterator<Ptr> for DecimalBuilder {
+    fn from_iter<I: IntoIterator<Item = Ptr>>(iter: I) -> Self {
+        let iter = iter.into_iter();
+        let (lower, upper) = iter.size_hint();
+        let size_hint = upper.unwrap_or(lower);
+        let fixed_len = 16_usize;
+
+        let mut builder = FixedSizeListBuilder::with_capacity(

Review Comment:
   Ah, right. I was too focused on building builders out of its sub components. I totally forgot that builder contains handy methods to append values. It was fun experience though. 
   
   You will noticed this to almost all implementation (except one). I'll update the PR.  



-- 
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-unsubscribe@arrow.apache.org

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