| 331 | |
| 332 | impl ImportedArrowArray<'_> { |
| 333 | fn consume(self) -> Result<ArrayData> { |
| 334 | let len = self.array.len(); |
| 335 | let offset = self.array.offset(); |
| 336 | let null_count = match &self.data_type { |
| 337 | DataType::Null => Some(0), |
| 338 | _ => self.array.null_count_opt(), |
| 339 | }; |
| 340 | |
| 341 | let data_layout = layout(&self.data_type); |
| 342 | let buffers = self.buffers(data_layout.can_contain_null_mask, data_layout.variadic)?; |
| 343 | |
| 344 | let null_bit_buffer = if data_layout.can_contain_null_mask { |
| 345 | self.null_bit_buffer() |
| 346 | } else { |
| 347 | None |
| 348 | }; |
| 349 | |
| 350 | let mut child_data = self.consume_children()?; |
| 351 | |
| 352 | if let Some(d) = self.dictionary()? { |
| 353 | // For dictionary type there should only be a single child, so we don't need to worry if |
| 354 | // there are other children added above. |
| 355 | assert!(child_data.is_empty()); |
| 356 | child_data.push(d.consume()?); |
| 357 | } |
| 358 | |
| 359 | // Should FFI be checking validity? |
| 360 | Ok(unsafe { |
| 361 | ArrayData::new_unchecked( |
| 362 | self.data_type, |
| 363 | len, |
| 364 | null_count, |
| 365 | null_bit_buffer, |
| 366 | offset, |
| 367 | buffers, |
| 368 | child_data, |
| 369 | ) |
| 370 | }) |
| 371 | } |
| 372 | |
| 373 | fn consume_children(&self) -> Result<Vec<ArrayData>> { |
| 374 | match &self.data_type { |