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

Function encode

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

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

(
    data: &mut [u8],
    offsets: &mut [usize],
    rows: &Rows,
    opts: SortOptions,
    array: &GenericListArray<O>,
)

Source from the content-addressed store, hash-verified

50///
51/// `rows` should contain the encoded child elements
52pub fn encode<O: OffsetSizeTrait>(
53 data: &mut [u8],
54 offsets: &mut [usize],
55 rows: &Rows,
56 opts: SortOptions,
57 array: &GenericListArray<O>,
58) {
59 let shift = array.value_offsets()[0].as_usize();
60
61 offsets
62 .iter_mut()
63 .skip(1)
64 .zip(array.value_offsets().windows(2))
65 .enumerate()
66 .for_each(|(idx, (offset, offsets))| {
67 let start = offsets[0].as_usize() - shift;
68 let end = offsets[1].as_usize() - shift;
69 let range = array.is_valid(idx).then_some(start..end);
70 let out = &mut data[*offset..];
71 *offset += encode_one(out, rows, range, opts)
72 });
73}
74
75#[inline]
76fn encode_one(

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected