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

Method pack

src/expr/src/scalar/func/impls/array.rs:133–160  ·  view source on GitHub ↗
(
            temp_storage: &RowArena,
            elems: &mut impl Iterator<Item = Datum<'a>>,
            dims: &[ArrayDimension],
            cast_element: &MirScalarExpr,
            packer: &mut 

Source from the content-addressed store, hash-verified

131 a: &'a impl Eval,
132 ) -> Result<Datum<'a>, EvalError> {
133 fn pack<'a>(
134 temp_storage: &RowArena,
135 elems: &mut impl Iterator<Item = Datum<'a>>,
136 dims: &[ArrayDimension],
137 cast_element: &MirScalarExpr,
138 packer: &mut RowPacker,
139 ) -> Result<(), EvalError> {
140 packer.push_list_with(|packer| match dims {
141 [] => Ok(()),
142 [dim] => {
143 for _ in 0..dim.length {
144 let elem = elems.next().unwrap();
145 let elem = match cast_element.eval(&[elem], temp_storage)? {
146 Datum::Null => Datum::JsonNull,
147 d => d,
148 };
149 packer.push(elem);
150 }
151 Ok(())
152 }
153 [dim, rest @ ..] => {
154 for _ in 0..dim.length {
155 pack(temp_storage, elems, rest, cast_element, packer)?;
156 }
157 Ok(())
158 }
159 })
160 }
161
162 let a = a.eval(datums, temp_storage)?;
163 if a.is_null() {

Callers

nothing calls this directly

Calls 6

packFunction · 0.85
push_list_withMethod · 0.80
unwrapMethod · 0.80
nextMethod · 0.45
evalMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected