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

Function encode_list_view

arrow-row/src/list.rs:368–398  ·  view source on GitHub ↗

Encodes the provided `GenericListViewArray` to `out` with the provided `SortOptions` `rows` should contain the encoded child elements

(
    data: &mut [u8],
    out_offsets: &mut [usize],
    rows: &Rows,
    opts: SortOptions,
    array: &GenericListViewArray<O>,
    shift: usize,
)

Source from the content-addressed store, hash-verified

366///
367/// `rows` should contain the encoded child elements
368pub fn encode_list_view<O: OffsetSizeTrait>(
369 data: &mut [u8],
370 out_offsets: &mut [usize],
371 rows: &Rows,
372 opts: SortOptions,
373 array: &GenericListViewArray<O>,
374 shift: usize,
375) {
376 let offsets = array.value_offsets();
377 let sizes = array.value_sizes();
378
379 out_offsets
380 .iter_mut()
381 .skip(1)
382 .enumerate()
383 .for_each(|(idx, offset)| {
384 let size = sizes[idx].as_usize();
385 let range = array.is_valid(idx).then(|| {
386 // For empty lists (size=0), offset may be arbitrary and could underflow when shifted.
387 // Use 0 as start since the range is empty anyway.
388 let start = if size > 0 {
389 offsets[idx].as_usize() - shift
390 } else {
391 0
392 };
393 start..start + size
394 });
395 let out = &mut data[*offset..];
396 *offset += encode_one(out, rows, range, opts)
397 });
398}
399
400/// Decodes a `GenericListViewArray` from `rows` with the provided `options`
401///

Callers 1

encode_columnFunction · 0.85

Calls 6

value_sizesMethod · 0.80
as_usizeMethod · 0.80
encode_oneFunction · 0.70
value_offsetsMethod · 0.45
skipMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected