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

Function decode

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

Decodes an array from `rows` with the provided `options` # Safety `rows` must contain valid data for the provided `converter`

(
    converter: &RowConverter,
    rows: &mut [&[u8]],
    field: &SortField,
    validate_utf8: bool,
)

Source from the content-addressed store, hash-verified

100///
101/// `rows` must contain valid data for the provided `converter`
102pub unsafe fn decode<O: OffsetSizeTrait>(
103 converter: &RowConverter,
104 rows: &mut [&[u8]],
105 field: &SortField,
106 validate_utf8: bool,
107) -> Result<GenericListArray<O>, ArrowError> {
108 let opts = field.options;
109
110 let mut values_bytes = 0;
111
112 let mut offset = 0;
113 let mut offsets = Vec::with_capacity(rows.len() + 1);
114 offsets.push(O::usize_as(0));
115
116 for row in rows.iter_mut() {
117 let mut row_offset = 0;
118 loop {
119 let decoded = super::variable::decode_blocks(&row[row_offset..], opts, |x| {
120 values_bytes += x.len();
121 });
122 if decoded <= 1 {
123 offsets.push(O::usize_as(offset));
124 break;
125 }
126 row_offset += decoded;
127 offset += 1;
128 }
129 }
130 O::from_usize(offset).expect("overflow");
131
132 let mut null_count = 0;
133 let nulls = MutableBuffer::collect_bool(rows.len(), |x| {
134 let valid = rows[x][0] != null_sentinel(opts);
135 null_count += !valid as usize;
136 valid
137 });
138
139 let mut values_offsets = Vec::with_capacity(offset);
140 let mut values_bytes = Vec::with_capacity(values_bytes);
141 for row in rows.iter_mut() {
142 let mut row_offset = 0;
143 loop {
144 let decoded = super::variable::decode_blocks(&row[row_offset..], opts, |x| {
145 values_bytes.extend_from_slice(x)
146 });
147 row_offset += decoded;
148 if decoded <= 1 {
149 break;
150 }
151 values_offsets.push(values_bytes.len());
152 }
153 *row = &row[row_offset..];
154 }
155
156 if opts.descending {
157 values_bytes.iter_mut().for_each(|o| *o = !*o);
158 }
159

Callers

nothing calls this directly

Calls 15

decode_blocksFunction · 0.85
collect_boolFunction · 0.85
null_sentinelFunction · 0.85
LargeListClass · 0.85
extend_from_sliceMethod · 0.80
collectMethod · 0.80
convert_rawMethod · 0.80
add_child_dataMethod · 0.80
add_bufferMethod · 0.80
ListClass · 0.50
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected