Skip to content

Commit

Permalink
Add validity to the inner elements of fixed-sized-lists
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Aug 15, 2023
1 parent 9aa6aa2 commit a828441
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions crates/re_types_builder/src/codegen/rust/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,34 @@ fn quote_arrow_field_serializer(
}
};

// TODO(jleibs): The inner types of lists shouldn't be nullable, but both the python and
// C++ code-gen end up setting these to null when an outer fixed-sized field does happen
// to be null. In order to keep everything aligned at a validation level we match this
// behavior and create a validity-mask for the corresponding inner type. We can undo this if
// we make the C++ and Python codegen match the rust behavior or make our comparison tests
// more lenient.
let quoted_inner_bitmap =
if let DataType::FixedSizeList(_, count) = datatype.to_logical_type() {
quote! {
let #quoted_inner_bitmap: Option<::arrow2::bitmap::Bitmap>
= #bitmap_src
.as_ref()
.map(|bitmap| {
bitmap
.iter()
.map(|i| std::iter::repeat(i).take(#count))
.flatten()
.collect::<Vec<_>>()
.into()
});
}
} else {
// TODO(cmc): We don't support intra-list nullability in our IDL at the moment.
quote! {
let #quoted_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = None;
}
};

// TODO(cmc): We should be checking this, but right now we don't because we don't
// support intra-list nullability.
_ = is_nullable;
Expand All @@ -564,8 +592,7 @@ fn quote_arrow_field_serializer(
.map(Some)
.collect();

// TODO(cmc): We don't support intra-list nullability in our IDL at the moment.
let #quoted_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = None;
#quoted_inner_bitmap

#quoted_create
}}
Expand Down

0 comments on commit a828441

Please sign in to comment.