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

Commit

Permalink
Added constructor new_from (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohav authored Jul 17, 2022
1 parent adac2b8 commit 3fdb33f
Showing 1 changed file with 10 additions and 7 deletions.
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 {
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

0 comments on commit 3fdb33f

Please sign in to comment.