MCPcopy Create free account
hub / github.com/apache/arrow-rs / try_new

Method try_new

arrow-array/src/array/primitive_array.rs:654–673  ·  view source on GitHub ↗

Create a new [`PrimitiveArray`] from the provided values and nulls # Errors Errors if: - `values.len() != nulls.len()`

(
        values: ScalarBuffer<T::Native>,
        nulls: Option<NullBuffer>,
    )

Source from the content-addressed store, hash-verified

652 /// Errors if:
653 /// - `values.len() != nulls.len()`
654 pub fn try_new(
655 values: ScalarBuffer<T::Native>,
656 nulls: Option<NullBuffer>,
657 ) -> Result<Self, ArrowError> {
658 if let Some(n) = nulls.as_ref() {
659 if n.len() != values.len() {
660 return Err(ArrowError::InvalidArgumentError(format!(
661 "Incorrect length of null buffer for PrimitiveArray, expected {} got {}",
662 values.len(),
663 n.len(),
664 )));
665 }
666 }
667
668 Ok(Self {
669 data_type: T::DATA_TYPE,
670 values,
671 nulls,
672 })
673 }
674
675 /// Create a new [`Scalar`] from `value`
676 pub fn new_scalar(value: T::Native) -> Scalar<Self> {

Callers

nothing calls this directly

Calls 2

as_refMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected