klion26 commented on code in PR #7987:
URL: https://github.com/apache/arrow-rs/pull/7987#discussion_r2227352892


##########
parquet-variant/src/builder.rs:
##########
@@ -1216,24 +1245,46 @@ impl<'a> ListBuilder<'a> {
 
     /// Finalizes this list and appends it to its parent, which otherwise 
remains unmodified.
     pub fn finish(mut self) {
-        let data_size = self.buffer.offset();
+        let buffer = self.parent_state.buffer();
+
+        let data_size = buffer.offset() - self.parent_value_offset_base;
+
         let num_elements = self.offsets.len();
         let is_large = num_elements > u8::MAX as usize;
         let offset_size = int_size(data_size);
 
-        // Get parent's buffer
-        let parent_buffer = self.parent_state.buffer();
-        let starting_offset = parent_buffer.offset();
+        let starting_offset = self.parent_value_offset_base;
 
         // Write header
         let header = array_header(is_large, offset_size);
-        parent_buffer.append_header(header, is_large, num_elements);
 
-        // Write out the offset array followed by the value bytes
-        let offsets = std::mem::take(&mut self.offsets);
-        parent_buffer.append_offset_array(offsets, Some(data_size), 
offset_size);
-        parent_buffer.append_slice(self.buffer.inner());
+        let num_elements_bytes =
+            num_elements
+                .to_le_bytes()
+                .into_iter()
+                .take(if is_large { 4 } else { 1 });
+        let offsets = PackedU32Iterator::new(
+            offset_size as usize,
+            self.offsets
+                .clone()

Review Comment:
   Add `clone()` here to make compile happy, or the compile will throw `cannot 
move out of type `ListBuilder<'_>`, which implements the `Drop` trait`



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