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

Method try_new

arrow-array/src/array/byte_view_array.rs:204–234  ·  view source on GitHub ↗

Create a new [`GenericByteViewArray`] from the provided parts, returning an error on failure # Errors `views.len() != nulls.len()` [ByteViewType::validate] fails

(
        views: ScalarBuffer<u128>,
        buffers: U,
        nulls: Option<NullBuffer>,
    )

Source from the content-addressed store, hash-verified

202 /// * `views.len() != nulls.len()`
203 /// * [ByteViewType::validate] fails
204 pub fn try_new<U>(
205 views: ScalarBuffer<u128>,
206 buffers: U,
207 nulls: Option<NullBuffer>,
208 ) -> Result<Self, ArrowError>
209 where
210 U: Into<Arc<[Buffer]>>,
211 {
212 let buffers: Arc<[Buffer]> = buffers.into();
213
214 T::validate(&views, &buffers)?;
215
216 if let Some(n) = nulls.as_ref() {
217 if n.len() != views.len() {
218 return Err(ArrowError::InvalidArgumentError(format!(
219 "Incorrect length of null buffer for {}ViewArray, expected {} got {}",
220 T::PREFIX,
221 views.len(),
222 n.len(),
223 )));
224 }
225 }
226
227 Ok(Self {
228 data_type: T::DATA_TYPE,
229 views,
230 buffers,
231 nulls,
232 phantom: Default::default(),
233 })
234 }
235
236 /// Create a new [`GenericByteViewArray`] from the provided parts, without validation
237 ///

Callers

nothing calls this directly

Calls 4

validateFunction · 0.85
defaultFunction · 0.85
as_refMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected