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


##########
parquet-variant/src/variant/object.rs:
##########
@@ -400,6 +400,8 @@ impl<'m, 'v> VariantObject<'m, 'v> {
 
 #[cfg(test)]
 mod tests {
+    use crate::VariantBuilder;
+
     use super::*;
 
     #[test]

Review Comment:
   The comment in line 411 seems incorrect -- `So header byte = 00_0_1_0001 = 
0x10`. Maybe we can improve it also



##########
parquet-variant/src/variant/object.rs:
##########
@@ -618,4 +620,116 @@ mod tests {
             ArrowError::InvalidArgumentError(ref msg) if msg.contains("Tried 
to extract byte(s) ..16 from 15-byte buffer")
         ));
     }
+
+    fn test_variant_object_with_count(count: i32, expected_field_id_size: 
OffsetSizeBytes) {
+        let field_names: Vec<_> = (0..count).map(|val| 
val.to_string()).collect();
+        let mut builder =
+            VariantBuilder::new().with_field_names(field_names.iter().map(|s| 
s.as_str()));
+
+        let mut obj = builder.new_object();
+
+        for i in 0..count {
+            obj.insert(&field_names[i as usize], i);
+        }
+
+        obj.finish().unwrap();
+        let (metadata, value) = builder.finish();
+        let variant = Variant::new(&metadata, &value);
+
+        if let Variant::Object(obj) = variant {
+            assert_eq!(obj.len(), count as usize);
+
+            assert_eq!(obj.get(&field_names[0]).unwrap(), Variant::Int32(0));
+            assert_eq!(
+                obj.get(&field_names[(count - 1) as usize]).unwrap(),
+                Variant::Int32(count - 1)
+            );
+
+            let header_byte = first_byte_from_slice(&value).unwrap();

Review Comment:
   1. Do we need to compute the header here? Seems we can get the header from 
`obj.header`
   2. Do we need to verify the `field_offset_size` in `VariantObjectHeader`



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