MCPcopy Create free account
hub / github.com/apache/arrow-rs / decode_fixed_size_binary

Function decode_fixed_size_binary

arrow-row/src/fixed.rs:481–515  ·  view source on GitHub ↗

Decodes a `FixedLengthBinary` from rows # Panics: Panics if `size` is negative

(
    rows: &mut [&[u8]],
    size: i32,
    options: SortOptions,
)

Source from the content-addressed store, hash-verified

479/// # Panics:
480/// Panics if `size` is negative
481pub fn decode_fixed_size_binary(
482 rows: &mut [&[u8]],
483 size: i32,
484 options: SortOptions,
485) -> FixedSizeBinaryArray {
486 let len = rows.len();
487
488 if size < 0 {
489 panic!("cannot decode FixedSizeBinary({size})");
490 }
491 let mut values = MutableBuffer::new(size as usize * rows.len());
492 let (null_count, nulls) = decode_nulls(rows);
493
494 let encoded_len = size as usize + 1;
495
496 for row in rows {
497 let i = split_off(row, encoded_len);
498 values.extend_from_slice(&i[1..]);
499 }
500
501 if options.descending {
502 for v in values.as_slice_mut() {
503 *v = !*v;
504 }
505 }
506
507 let builder = ArrayDataBuilder::new(DataType::FixedSizeBinary(size))
508 .len(len)
509 .null_count(null_count)
510 .add_buffer(values.into())
511 .null_bit_buffer(Some(nulls));
512
513 // SAFETY: Buffers correct length
514 unsafe { builder.build_unchecked().into() }
515}

Callers

nothing calls this directly

Calls 10

decode_nullsFunction · 0.85
split_offFunction · 0.85
FixedSizeBinaryClass · 0.85
extend_from_sliceMethod · 0.80
add_bufferMethod · 0.80
lenMethod · 0.45
as_slice_mutMethod · 0.45
null_bit_bufferMethod · 0.45
null_countMethod · 0.45
build_uncheckedMethod · 0.45

Tested by

no test coverage detected