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


##########
arrow-array/src/builder/generic_list_builder.rs:
##########
@@ -125,11 +125,97 @@ where
     /// Panics if the length of [`Self::values`] exceeds `OffsetSize::MAX`
     #[inline]
     pub fn append(&mut self, is_valid: bool) {
-        self.offsets_builder
-            
.append(OffsetSize::from_usize(self.values_builder.len()).unwrap());
+        self.offsets_builder.append(self.next_offset());
         self.null_buffer_builder.append(is_valid);
     }
 
+    /// Returns the next offset
+    ///
+    /// # Panics
+    ///
+    /// Panics if the length of [`Self::values`] exceeds `OffsetSize::MAX`
+    #[inline]
+    fn next_offset(&self) -> OffsetSize {
+        OffsetSize::from_usize(self.values_builder.len()).unwrap()
+    }
+
+    /// Append a value to this [`GenericListBuilder`]
+    ///
+    /// ```
+    /// # use arrow_array::builder::{Int32Builder, ListBuilder};
+    /// # use arrow_array::cast::AsArray;
+    /// # use arrow_array::{Array, Int32Array};
+    /// # use arrow_array::types::Int32Type;
+    /// let mut builder = ListBuilder::new(Int32Builder::new());
+    ///
+    /// builder.append_value([Some(1), Some(2), Some(3)]);

Review Comment:
   I think this is much easier to read than the current API



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