alamb commented on code in PR #12353:
URL: https://github.com/apache/arrow-rs/pull/12353#discussion_r4652031995


##########
arrow-array/src/builder/map_builder.rs:
##########
@@ -283,16 +277,10 @@ impl<K: ArrayBuilder, V: ArrayBuilder> MapBuilder<K, V> {
             struct_array.data_type().clone(),
             false, // always non-nullable
         ));
-        let array_data = ArrayData::builder(DataType::Map(map_field, false)) 
// TODO: support sorted keys
-            .len(len)
-            .add_buffer(offset_buffer)
-            .add_child_data(struct_array.into_data())
-            .nulls(nulls);
-
-        // SAFETY: builder is constructed from valid offset buffer and struct 
child array maintained by the builder
-        let array_data = unsafe { array_data.build_unchecked() };
-
-        MapArray::from(array_data)
+        // SAFETY: offsets are appended from the entry count, which the builder
+        // keeps equal for keys and values, and the entries are non-nullable
+        let offsets = unsafe { 
OffsetBuffer::new_unchecked(offset_buffer.into()) };
+        unsafe { MapArray::new_unchecked(map_field, offsets, struct_array, 
nulls, false) }

Review Comment:
   false in this case is `ordered` 👍 



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