Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Added constructor MutableFixedSizeListArray::new_from #1161

Merged
merged 3 commits into from
Jul 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/array/fixed_size_list/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ impl<M: MutableArray> MutableFixedSizeListArray<M> {
/// Creates a new [`MutableFixedSizeListArray`] from a [`MutableArray`] and size.
pub fn new(values: M, size: usize) -> Self {
let data_type = FixedSizeListArray::default_datatype(values.data_type().clone(), size);
assert_eq!(values.len(), 0);
Self {
size,
data_type,
values,
validity: None,
}
Self::new_from(values, data_type, size)
}

/// Creates a new [`MutableFixedSizeListArray`] from a [`MutableArray`] and size.
Expand All @@ -47,7 +41,16 @@ impl<M: MutableArray> MutableFixedSizeListArray<M> {
Box::new(Field::new(name, values.data_type().clone(), nullable)),
size,
);
Self::new_from(values, data_type, size)
}

/// Creates a new [`MutableFixedSizeListArray`] from a [`MutableArray`], [`DataType`] and size.
pub fn new_from(values: M, data_type: DataType, size: usize) -> Self {
jorgecarleitao marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(values.len(), 0);
match data_type {
DataType::FixedSizeList(..) => (),
_ => panic!("data type must be FixedSizeList (got {:?})", data_type),
};
Self {
size,
data_type,
Expand Down