tustvold commented on code in PR #1746:
URL: https://github.com/apache/arrow-rs/pull/1746#discussion_r883099621
##########
parquet/src/arrow/levels.rs:
##########
@@ -1760,63 +1002,152 @@ mod tests {
let array = Arc::new(list_builder.finish());
+ let values_len = array.data().child_data()[0].len();
+ assert_eq!(values_len, 5);
+
let schema = Arc::new(Schema::new(vec![list_field]));
let rb = RecordBatch::try_new(schema, vec![array]).unwrap();
- let batch_level = LevelInfo::new(0, rb.num_rows());
- let list_level =
- &batch_level.calculate_array_levels(rb.column(0),
rb.schema().field(0))[0];
+ let levels = calculate_array_levels(rb.column(0),
rb.schema().field(0)).unwrap();
+ let list_level = &levels[0];
let expected_level = LevelInfo {
- definition: vec![4, 1, 0, 2, 2, 3, 4],
- repetition: Some(vec![0, 0, 0, 0, 1, 0, 0]),
- array_offsets: vec![0, 1, 1, 1, 3, 4, 5],
- array_mask: vec![true, true, false, false, false, false, true],
- max_definition: 4,
- level_type: LevelType::Primitive(true),
- offset: 0,
- length: 5,
+ def_levels: Some(vec![4, 1, 0, 2, 2, 3, 4]),
+ rep_levels: Some(vec![0, 0, 0, 0, 1, 0, 0]),
+ non_null_indices: vec![0, 4],
+ max_def_level: 4,
+ max_rep_level: 1,
};
assert_eq!(list_level, &expected_level);
}
#[test]
- fn test_nested_indices() {
- // Given a buffer like
- // [0, null, null, 1, 2]
- //
- // The two level infos below might represent the two structures
- // 1: [{a: 0}], [], null, [null, null], [{a: 1}], [{a: 2}]
- // 2: [0], [], null, [null, null], [1], [2]
- //
- // (That is, their only difference is that the leaf values are nested
one level deeper in a
- // struct).
-
- let level1 = LevelInfo {
- definition: vec![4, 1, 0, 2, 2, 4, 4],
- repetition: Some(vec![0, 0, 0, 0, 1, 0, 0]),
- array_offsets: vec![0, 1, 1, 1, 3, 4, 5],
- array_mask: vec![true, true, false, false, false, false, true],
- max_definition: 4,
- level_type: LevelType::Primitive(true),
- offset: 0,
- length: 5,
+ fn test_struct_mask_list() {
+ // Test a struct array masking a list
Review Comment:
I've reworded to hopefully make it clearer
--
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]