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

Function delegated_decode

datafusion/functions/src/encoding/inner.rs:462–493  ·  view source on GitHub ↗
(
    decode: DecodeFunction,
    input: &InputBinaryArray,
    conservative_upper_bound_size: usize,
)

Source from the content-addressed store, hash-verified

460}
461
462fn delegated_decode<'a, DecodeFunction, InputBinaryArray, OutputOffset>(
463 decode: DecodeFunction,
464 input: &InputBinaryArray,
465 conservative_upper_bound_size: usize,
466) -> Result<ArrayRef>
467where
468 DecodeFunction: Fn(&[u8], &mut [u8]) -> Result<usize>,
469 InputBinaryArray: BinaryArrayType<'a>,
470 OutputOffset: OffsetSizeTrait,
471{
472 let mut values = vec![0; conservative_upper_bound_size];
473 let mut offsets = OffsetBufferBuilder::new(input.len());
474 let mut total_bytes_decoded = 0;
475 for v in input.iter() {
476 if let Some(v) = v {
477 let cursor = &mut values[total_bytes_decoded..];
478 let decoded = decode(v, cursor)?;
479 total_bytes_decoded += decoded;
480 offsets.push_length(decoded);
481 } else {
482 offsets.push_length(0);
483 }
484 }
485 // We reserved an upper bound size for the values buffer, but we only use the actual size
486 values.truncate(total_bytes_decoded);
487 let binary_array = GenericBinaryArray::<OutputOffset>::try_new(
488 offsets.finish(),
489 Buffer::from_vec(values),
490 input.nulls().cloned(),
491 )?;
492 Ok(Arc::new(binary_array))
493}
494
495#[cfg(test)]
496mod tests {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
lenMethod · 0.45
iterMethod · 0.45
truncateMethod · 0.45
finishMethod · 0.45
clonedMethod · 0.45
nullsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…