Process a map array with a nested key type by iterating through entries and using a comparator for key matching. This specialized version is used when the key type is nested (e.g., struct, list).
(
array: &dyn Array,
key_array: &dyn Array,
)
| 154 | /// |
| 155 | /// This specialized version is used when the key type is nested (e.g., struct, list). |
| 156 | fn process_map_with_nested_key( |
| 157 | array: &dyn Array, |
| 158 | key_array: &dyn Array, |
| 159 | ) -> Result<ColumnarValue> { |
| 160 | let map_array = as_map_array(array)?; |
| 161 | |
| 162 | let comparator = |
| 163 | make_comparator(map_array.keys().as_ref(), key_array, SortOptions::default())?; |
| 164 | |
| 165 | let original_data = map_array.entries().column(1).to_data(); |
| 166 | let capacity = Capacities::Array(original_data.len()); |
| 167 | let mut mutable = |
| 168 | MutableArrayData::with_capacities(vec![&original_data], true, capacity); |
| 169 | |
| 170 | for entry in 0..map_array.len() { |
| 171 | let start = map_array.value_offsets()[entry] as usize; |
| 172 | let end = map_array.value_offsets()[entry + 1] as usize; |
| 173 | |
| 174 | let mut found_match = false; |
| 175 | for i in start..end { |
| 176 | if comparator(i, 0).is_eq() { |
| 177 | mutable.extend(0, i, i + 1); |
| 178 | found_match = true; |
| 179 | break; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | if !found_match { |
| 184 | mutable.extend_nulls(1); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | let data = mutable.freeze(); |
| 189 | let data = make_array(data); |
| 190 | Ok(ColumnarValue::Array(data)) |
| 191 | } |
| 192 | |
| 193 | /// Extract a single field from a struct or map array |
| 194 | fn extract_single_field(base: ColumnarValue, name: ScalarValue) -> Result<ColumnarValue> { |
no test coverage detected
searching dependent graphs…