MCPcopy Create free account
hub / github.com/apache/datafusion / insert_if_new

Method insert_if_new

datafusion/physical-expr-common/src/binary_view_map.rs:206–235  ·  view source on GitHub ↗

Inserts each value from `values` into the map, invoking `payload_fn` for each value if *not* already present, deferring the allocation of the payload until it is needed. Note that this is different than a normal map that would replace the existing entry # Arguments: `values`: array whose values are inserted `make_payload_fn`: invoked for each value that is not already present to create the pa

(
        &mut self,
        values: &ArrayRef,
        make_payload_fn: MP,
        observe_payload_fn: OP,
    )

Source from the content-addressed store, hash-verified

204 /// Note that `make_payload_fn` and `observe_payload_fn` are only invoked
205 /// with valid values from `values`, not for the `NULL` value.
206 pub fn insert_if_new<MP, OP>(
207 &mut self,
208 values: &ArrayRef,
209 make_payload_fn: MP,
210 observe_payload_fn: OP,
211 ) where
212 MP: FnMut(Option<&[u8]>) -> V,
213 OP: FnMut(V),
214 {
215 // Sanity check array type
216 match self.output_type {
217 OutputType::BinaryView => {
218 assert!(matches!(values.data_type(), DataType::BinaryView));
219 self.insert_if_new_inner::<MP, OP, BinaryViewType>(
220 values,
221 make_payload_fn,
222 observe_payload_fn,
223 )
224 }
225 OutputType::Utf8View => {
226 assert!(matches!(values.data_type(), DataType::Utf8View));
227 self.insert_if_new_inner::<MP, OP, StringViewType>(
228 values,
229 make_payload_fn,
230 observe_payload_fn,
231 )
232 }
233 _ => unreachable!("Utf8/Binary should use `ArrowBytesSet`"),
234 };
235 }
236
237 /// Generic version of [`Self::insert_if_new`] that handles `ByteViewType`
238 /// (both StringView and BinaryView)

Callers 1

insertMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected