jecsand838 commented on code in PR #8349:
URL: https://github.com/apache/arrow-rs/pull/8349#discussion_r2369123523
##########
arrow-avro/src/reader/record.rs:
##########
@@ -1193,88 +900,9 @@ impl Decoder {
let nanos = (millis as i64) * 1_000_000;
builder.append_value(IntervalMonthDayNano::new(months as i32,
days as i32, nanos));
}
- Self::Union(fields, type_ids, offsets, encodings, encoding_counts,
None) => {
- let branch = buf.get_long()?;
- if branch < 0 {
- return Err(ArrowError::ParseError(format!(
- "Negative union branch index {branch}"
- )));
- }
- let idx = branch as usize;
- if idx >= encodings.len() {
- return Err(ArrowError::ParseError(format!(
- "Union branch index {idx} out of range ({} branches)",
- encodings.len()
- )));
- }
- let type_id = fields
- .iter()
- .nth(idx)
- .map(|(type_id, _)| type_id)
- .unwrap_or_else(|| i8::try_from(idx).unwrap_or(0));
- type_ids.push(type_id);
- offsets.push(encoding_counts[idx]);
- encodings[idx].decode(buf)?;
- encoding_counts[idx] += 1;
- }
- Self::Union(
- _,
- type_ids,
- offsets,
- encodings,
- encoding_counts,
- Some(union_resolution),
- ) => match &mut union_resolution.kind {
- UnionResolvedKind::Both {
- reader_type_codes, ..
- } => {
- let (idx, action) = get_writer_union_action!(buf,
union_resolution);
- match action {
- BranchDispatch::NoMatch => {
- return Err(ArrowError::ParseError(format!(
- "Union branch index {idx} not resolvable by
reader schema"
- )));
- }
- BranchDispatch::ToReader {
- reader_idx,
- promotion,
- } => {
- let type_id = reader_type_codes[reader_idx];
- type_ids.push(type_id);
- offsets.push(encoding_counts[reader_idx]);
- encodings[reader_idx].decode_with_promotion(buf,
promotion)?;
- encoding_counts[reader_idx] += 1;
- }
- }
- }
- UnionResolvedKind::ToSingle { target } => {
- let (idx, action) = get_writer_union_action!(buf,
union_resolution);
- match action {
- BranchDispatch::NoMatch => {
- return Err(ArrowError::ParseError(format!(
- "Writer union branch {idx} does not resolve to
reader type"
- )));
- }
- BranchDispatch::ToReader { promotion, .. } => {
- target.decode_with_promotion(buf, promotion)?;
- }
- }
- }
- UnionResolvedKind::FromSingle {
- reader_type_codes,
- target_reader_index,
- promotion,
- ..
- } => {
- let type_id = reader_type_codes[*target_reader_index];
- type_ids.push(type_id);
- offsets.push(encoding_counts[*target_reader_index]);
- encodings[*target_reader_index].decode_with_promotion(buf,
*promotion)?;
- encoding_counts[*target_reader_index] += 1;
- }
- },
+ Self::Union(u) => u.decode(buf)?,
Self::Nullable(order, nb, encoding) => {
- let branch = buf.get_long()?;
+ let branch = buf.read_vlq()?;
Review Comment:
If you mean inside of the `Self::Nullable(order, nb, encoding) => {`
branches, it ended up being a red herring I came across when debugging last
week. I had forgotten to change it back.
--
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]