alamb commented on code in PR #4065:
URL: https://github.com/apache/arrow-rs/pull/4065#discussion_r1167831840
##########
arrow-array/src/array/list_array.rs:
##########
@@ -73,13 +74,102 @@ impl<OffsetSize: OffsetSizeTrait>
GenericListArray<OffsetSize> {
/// The data type constructor of list array.
/// The input is the schema of the child array and
/// the output is the [`DataType`], List or LargeList.
- pub const DATA_TYPE_CONSTRUCTOR: fn(Arc<Field>) -> DataType = if
OffsetSize::IS_LARGE
- {
+ pub const DATA_TYPE_CONSTRUCTOR: fn(FieldRef) -> DataType = if
OffsetSize::IS_LARGE {
DataType::LargeList
} else {
DataType::List
};
+ /// Create a new [`GenericListArray`] from the provided parts
+ ///
+ /// # Errors
+ ///
+ /// Errors if
+ ///
+ /// * `offsets.len() - 1 != nulls.len()`
+ /// * `offsets.last() > values.len()`
+ /// * `!field.is_nullable() && values.null_count() != 0`
+ pub fn try_new(
+ field: FieldRef,
+ offsets: OffsetBuffer<OffsetSize>,
+ values: ArrayRef,
+ nulls: Option<NullBuffer>,
+ ) -> Result<Self, ArrowError> {
+ let len = offsets.len() - 1; // Offsets guaranteed to not be empty
+ let end_offset = offsets.last().unwrap().as_usize();
+ if end_offset > values.len() {
Review Comment:
```suggestion
// don't need to check other values of `offsets` because they are
checked
// during construction of `OffsetsbBuffer`
if end_offset > values.len() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]