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,
)
| 100 | /// |
| 101 | /// `rows` must contain valid data for the provided `converter` |
| 102 | pub 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 |
nothing calls this directly
no test coverage detected