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

Method insert_if_new

datafusion/physical-expr-common/src/binary_map.rs:293–328  ·  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

291 /// Note that `make_payload_fn` and `observe_payload_fn` are only invoked
292 /// with valid values from `values`, not for the `NULL` value.
293 pub fn insert_if_new<MP, OP>(
294 &mut self,
295 values: &ArrayRef,
296 make_payload_fn: MP,
297 observe_payload_fn: OP,
298 ) where
299 MP: FnMut(Option<&[u8]>) -> V,
300 OP: FnMut(V),
301 {
302 // Sanity array type
303 match self.output_type {
304 OutputType::Binary => {
305 assert!(matches!(
306 values.data_type(),
307 DataType::Binary | DataType::LargeBinary
308 ));
309 self.insert_if_new_inner::<MP, OP, GenericBinaryType<O>>(
310 values,
311 make_payload_fn,
312 observe_payload_fn,
313 )
314 }
315 OutputType::Utf8 => {
316 assert!(matches!(
317 values.data_type(),
318 DataType::Utf8 | DataType::LargeUtf8
319 ));
320 self.insert_if_new_inner::<MP, OP, GenericStringType<O>>(
321 values,
322 make_payload_fn,
323 observe_payload_fn,
324 )
325 }
326 _ => unreachable!("View types should use `ArrowBytesViewMap`"),
327 };
328 }
329
330 /// Generic version of [`Self::insert_if_new`] that handles `ByteArrayType`
331 /// (both String and Binary)

Callers 3

internMethod · 0.45
internMethod · 0.45
insertMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected