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

Adding new constructor for MutableListArray #1503

Merged
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: 17 additions & 0 deletions src/array/list/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@
Self::new_from(values, data_type, capacity)
}

/// Creates a new [`MutableListArray`] from a [`MutableArray`], [`Offsets`] and
/// [`MutableBitmap`].
pub fn new_from_mutable(
values: M,
offsets: Offsets<O>,
validity: Option<MutableBitmap>,
) -> Self {
assert_eq!(values.len(), offsets.last().to_usize());
let data_type = values.data_type().clone();
sundy-li marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sundy-li, thanks for the quick response. Unfortunately I missed on the dtype -- it should be the following:

        let data_type = ListArray::<O>::default_datatype(values.data_type().clone());

Self {
data_type,
offsets,
values,
validity,
}
}

Check warning on line 160 in src/array/list/mutable.rs

View check run for this annotation

Codecov / codecov/patch

src/array/list/mutable.rs#L147-L160

Added lines #L147 - L160 were not covered by tests

#[inline]
/// Needs to be called when a valid value was extended to this array.
/// This is a relatively low level function, prefer `try_push` when you can.
Expand Down
Loading