If `list` is sliced, returns an adjusted offset buffer so that it points to the sliced portion of the list values, and not the whole list values
(
list: &GenericListArray<O>,
)
| 1100 | /// If `list` is sliced, returns an adjusted offset buffer so that |
| 1101 | /// it points to the sliced portion of the list values, and not the whole list values |
| 1102 | pub fn adjust_offsets_for_slice<O: OffsetSizeTrait>( |
| 1103 | list: &GenericListArray<O>, |
| 1104 | ) -> OffsetBuffer<O> { |
| 1105 | let offsets = list.offsets(); |
| 1106 | |
| 1107 | if let (Some(first), Some(last)) = (offsets.first(), offsets.last()) |
| 1108 | && (!first.is_zero() || last.as_usize() != list.values().len()) |
| 1109 | { |
| 1110 | let offsets = offsets.iter().map(|offset| *offset - *first).collect(); |
| 1111 | |
| 1112 | //todo: use unsafe Offset::new_unchecked? |
| 1113 | return OffsetBuffer::new(offsets); |
| 1114 | } |
| 1115 | |
| 1116 | offsets.clone() |
| 1117 | } |
| 1118 | |
| 1119 | /// For lists and large lists, truncates the sublist of null values |
| 1120 | /// Otherwise returns an error |
no test coverage detected
searching dependent graphs…