(
ctx: &DecoderContext,
data_type: &DataType,
is_nullable: bool,
)
| 37 | |
| 38 | impl MapArrayDecoder { |
| 39 | pub fn new( |
| 40 | ctx: &DecoderContext, |
| 41 | data_type: &DataType, |
| 42 | is_nullable: bool, |
| 43 | ) -> Result<Self, ArrowError> { |
| 44 | let (entries_field, ordered) = match data_type { |
| 45 | DataType::Map(_, true) => { |
| 46 | return Err(ArrowError::NotYetImplemented( |
| 47 | "Decoding MapArray with sorted fields".to_string(), |
| 48 | )); |
| 49 | } |
| 50 | DataType::Map(f, ordered) => (f.clone(), *ordered), |
| 51 | _ => unreachable!(), |
| 52 | }; |
| 53 | |
| 54 | let key_value_fields = match entries_field.data_type() { |
| 55 | DataType::Struct(fields) if fields.len() == 2 => fields.clone(), |
| 56 | d => { |
| 57 | return Err(ArrowError::InvalidArgumentError(format!( |
| 58 | "MapArray must contain struct with two fields, got {d}" |
| 59 | ))); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | let keys = ctx.make_decoder( |
| 64 | key_value_fields[0].data_type(), |
| 65 | key_value_fields[0].is_nullable(), |
| 66 | )?; |
| 67 | let values = ctx.make_decoder( |
| 68 | key_value_fields[1].data_type(), |
| 69 | key_value_fields[1].is_nullable(), |
| 70 | )?; |
| 71 | |
| 72 | Ok(Self { |
| 73 | entries_field, |
| 74 | key_value_fields, |
| 75 | ordered, |
| 76 | keys, |
| 77 | values, |
| 78 | ignore_type_conflicts: ctx.ignore_type_conflicts(), |
| 79 | is_nullable, |
| 80 | }) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | impl ArrayDecoder for MapArrayDecoder { |
nothing calls this directly
no test coverage detected