Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ArrayView based Deserialization #200

Merged
merged 14 commits into from
Jul 24, 2024
23 changes: 13 additions & 10 deletions serde_arrow/src/arrow2_impl/deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::internal::{
outer_sequence_deserializer::OuterSequenceDeserializer,
string_deserializer::StringDeserializer,
struct_deserializer::StructDeserializer,
time_deserializer::TimeDeserializer,
utils::{check_supported_list_layout, BitBuffer},
},
deserializer::Deserializer,
Expand Down Expand Up @@ -88,7 +89,7 @@ pub fn build_array_deserializer<'a>(
) -> Result<ArrayDeserializer<'a>> {
use GenericDataType as T;
match &field.data_type {
T::Null => Ok(NullDeserializer.into()),
T::Null => Ok(ArrayDeserializer::Null(NullDeserializer)),
T::Bool => build_bool_deserializer(field, array),
T::U8 => build_integer_deserializer::<u8>(field, array),
T::U16 => build_integer_deserializer::<u16>(field, array),
Expand All @@ -104,16 +105,16 @@ pub fn build_array_deserializer<'a>(
T::Decimal128(_, _) => build_decimal128_deserializer(field, array),
T::Date32 => build_date32_deserializer(field, array),
T::Date64 => build_date64_deserializer(field, array),
T::Time32(_) => construction::build_time32_deserializer(
field,
T::Time32(unit) => Ok(ArrayDeserializer::Time32(TimeDeserializer::new(
as_primitive_values::<i32>(array)?,
get_validity(array),
),
T::Time64(_) => construction::build_time64_deserializer(
field,
*unit,
))),
T::Time64(unit) => Ok(ArrayDeserializer::Time64(TimeDeserializer::new(
as_primitive_values::<i64>(array)?,
get_validity(array),
),
*unit,
))),
T::Timestamp(_, _) => construction::build_timestamp_deserializer(
field,
as_primitive_values::<i64>(array)?,
Expand Down Expand Up @@ -151,7 +152,9 @@ pub fn build_bool_deserializer<'a>(
};
let validity = get_validity(array);

Ok(BoolDeserializer::new(buffer, validity).into())
Ok(ArrayDeserializer::Bool(BoolDeserializer::new(
buffer, validity,
)))
}

pub fn build_integer_deserializer<'a, T>(
Expand Down Expand Up @@ -367,7 +370,7 @@ where
};
let item = build_array_deserializer(item_field, array.values().as_ref())?;

Ok(ListDeserializer::new(item, offsets, validity).into())
Ok(ListDeserializer::new(item, offsets, validity)?.into())
}

pub fn build_map_deserializer<'a>(
Expand Down Expand Up @@ -404,7 +407,7 @@ pub fn build_map_deserializer<'a>(
let keys = build_array_deserializer(keys_field, keys.as_ref())?;
let values = build_array_deserializer(values_field, values.as_ref())?;

Ok(MapDeserializer::new(keys, values, offsets, validity).into())
Ok(MapDeserializer::new(keys, values, offsets, validity)?.into())
}

pub fn build_union_deserializer<'a>(
Expand Down
Loading