martin-g commented on code in PR #8839:
URL: https://github.com/apache/arrow-rs/pull/8839#discussion_r2527320326
##########
arrow-row/src/lib.rs:
##########
@@ -1637,6 +1733,49 @@ fn encode_column(
},
_ => unreachable!(),
},
+ Encoder::Union {
+ child_rows,
+ type_ids,
+ offsets: offsets_buf,
+ mode,
+ } => {
+ let _union_array =
column.as_any().downcast_ref::<UnionArray>().unwrap();
Review Comment:
```suggestion
```
since it is not used
##########
arrow-row/src/lib.rs:
##########
@@ -1762,6 +1901,110 @@ unsafe fn decode_column(
},
_ => unreachable!(),
},
+ Codec::Union(converters, null_rows, _mode) => {
+ let len = rows.len();
+
+ let DataType::Union(union_fields, mode) = &field.data_type else {
+ unreachable!()
Review Comment:
```suggestion
unreachable!("Expected a Union but got: {}",
&field.data_type)
```
##########
arrow-row/src/lib.rs:
##########
@@ -1523,6 +1592,33 @@ fn row_lengths(cols: &[ArrayRef], encoders: &[Encoder])
-> LengthTracker {
},
_ => unreachable!(),
},
+ Encoder::Union {
+ child_rows,
+ type_ids,
+ offsets,
+ mode,
+ } => {
+ let union_array =
array.as_any().downcast_ref::<UnionArray>().unwrap();
Review Comment:
```suggestion
let union_array =
array.as_any().downcast_ref::<UnionArray>().expect("expected Union array");
```
as at line 631
##########
arrow-row/src/lib.rs:
##########
@@ -592,6 +624,29 @@ impl Codec {
let rows =
converter.convert_columns(std::slice::from_ref(values))?;
Ok(Encoder::RunEndEncoded(rows))
}
+ Codec::Union(converters, _, mode) => {
+ let union_array = array
+ .as_any()
+ .downcast_ref::<UnionArray>()
+ .expect("expected Union array");
+
+ let type_ids = union_array.type_ids().clone();
+ let offsets = union_array.offsets().cloned();
+
+ let mut child_rows = Vec::with_capacity(converters.len());
+ for (type_id, converter) in converters.iter().enumerate() {
+ let child_array = union_array.child(type_id as i8);
Review Comment:
Here `type_id` is the index of the converter. It looks strange but it might
be OK.
Could you use the items in `type_ids` instead ?
##########
arrow-row/src/lib.rs:
##########
@@ -524,6 +527,35 @@ impl Codec {
Ok(Self::Struct(converter, owned))
}
+ DataType::Union(fields, mode) => {
+ // similar to dictionaries and lists, we set descending to
false and negate nulls_first
+ // since the encodedc ontents will be inverted if descending
is set
Review Comment:
```suggestion
// since the encoded contents will be inverted if descending
is set
```
--
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]