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/04/20 15:47:57 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #1602: Don't access and validate offset buffer in ListArray::from(ArrayData)

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


##########
arrow/src/array/array_list.rs:
##########
@@ -524,6 +516,32 @@ mod tests {
         assert_eq!(list_array, another)
     }
 
+    #[test]
+    fn test_empty_list_array() {
+        // Construct an empty value array
+        let value_data = ArrayData::builder(DataType::Int32)
+            .len(0)
+            .add_buffer(Buffer::from_iter(std::iter::empty::<i32>()))
+            .build()
+            .unwrap();
+
+        // Construct an empty offset buffer
+        let value_offsets = Buffer::from_iter(std::iter::empty::<i32>());

Review Comment:
   `Buffer::from([])` might be slightly cleaner?



##########
arrow/src/array/array_list.rs:
##########
@@ -1110,8 +1128,7 @@ mod tests {
     }
 
     #[test]
-    #[should_panic(expected = "offsets do not start at zero")]
-    fn test_list_array_invalid_value_offset_start() {
+    fn test_list_array_offsets_need_not_start_at_zero() {

Review Comment:
   The spec doesn't explicitly state either way on this, however, for variable length lists (e.g. UTF-8) it states
   
   > Generally the first slot in the offsets array is 0, and the last slot is the length of the values array. When serializing this layout, we recommend normalizing the offsets to start at 0.
   
   So I think this is likely correct



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