MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / try_push_array

Method try_push_array

src/repr/src/row.rs:2443–2463  ·  view source on GitHub ↗

Convenience function to construct an array from an iter of `Datum`s. Returns an error if the number of elements in `iter` does not match the cardinality of the array as described by `dims`, or if the number of dimensions exceeds [`MAX_ARRAY_DIMENSIONS`]. If an error occurs, the packer's state will be unchanged.

(
        &mut self,
        dims: &[ArrayDimension],
        iter: I,
    )

Source from the content-addressed store, hash-verified

2441 /// number of dimensions exceeds [`MAX_ARRAY_DIMENSIONS`]. If an error
2442 /// occurs, the packer's state will be unchanged.
2443 pub fn try_push_array<'a, I, D>(
2444 &mut self,
2445 dims: &[ArrayDimension],
2446 iter: I,
2447 ) -> Result<(), InvalidArrayError>
2448 where
2449 I: IntoIterator<Item = D>,
2450 D: Borrow<Datum<'a>>,
2451 {
2452 // SAFETY: The function returns the exact number of elements pushed into the array.
2453 unsafe {
2454 self.push_array_with_unchecked(dims, |packer| {
2455 let mut nelements = 0;
2456 for datum in iter {
2457 packer.push(datum);
2458 nelements += 1;
2459 }
2460 Ok::<_, InvalidArrayError>(nelements)
2461 })
2462 }
2463 }
2464
2465 /// Like [`RowPacker::try_push_array`], but accepts a fallible iterator of
2466 /// elements.

Callers 15

array_concatFunction · 0.80
regexp_matchesFunction · 0.80
regexp_split_to_array_reFunction · 0.80
regexp_match_staticFunction · 0.80
array_create_scalarFunction · 0.80
array_removeFunction · 0.80
array_array_concatFunction · 0.80
array_create_multidimFunction · 0.80
array_fillFunction · 0.80
string_to_arrayFunction · 0.80
string_to_array_implFunction · 0.80

Calls 2

pushMethod · 0.45

Tested by 6

test_arrayFunction · 0.64
test_has_int2vector_dimsFunction · 0.64