askoa commented on code in PR #3622:
URL: https://github.com/apache/arrow-rs/pull/3622#discussion_r1096543574
##########
arrow-array/src/array/run_array.rs:
##########
@@ -718,14 +790,62 @@ mod tests {
let run_array = builder.finish();
let typed = run_array.downcast::<PrimitiveArray<Int32Type>>().unwrap();
+ // Access every index and check if the value in the input array
matches returned value.
for (i, inp_val) in input_array.iter().enumerate() {
if let Some(val) = inp_val {
let actual = typed.value(i);
assert_eq!(*val, actual)
} else {
- let physical_ix = typed.get_physical_index(i).unwrap();
+ let physical_ix = run_array.get_physical_index(i).unwrap();
assert!(typed.values().is_null(physical_ix));
};
}
}
+
+ #[test]
+ fn test_get_physical_indices() {
+ let mut logical_len = 10;
+ // Test for logical lengths starting from 10 to 250 increasing by 10
+ while logical_len < 260 {
+ let input_array = build_input_array(logical_len);
+
+ // create run array using input_array
+ let mut builder = PrimitiveRunBuilder::<Int32Type,
Int32Type>::new();
+ builder.extend(input_array.clone().into_iter());
+
+ let run_array = builder.finish();
+ let physical_values_array =
+ run_array.downcast::<Int32Array>().unwrap().values();
+
+ // create an array consisiting of all the indices shuffled.
+ let mut logical_indices: Vec<u32> = (0_u32..(logical_len as
u32)).collect();
Review Comment:
Nice test case. Thanks for the suggestion.
--
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]