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

Method consume

arrow-array/src/ffi.rs:333–371  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

331
332impl 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 {

Callers 7

readMethod · 0.45
read_headerFunction · 0.45
readMethod · 0.45
from_ffiFunction · 0.45
from_ffi_and_data_typeFunction · 0.45
consume_childMethod · 0.45

Calls 9

layoutFunction · 0.85
consume_childrenMethod · 0.80
lenMethod · 0.45
offsetMethod · 0.45
null_count_optMethod · 0.45
buffersMethod · 0.45
null_bit_bufferMethod · 0.45
dictionaryMethod · 0.45
pushMethod · 0.45

Tested by 1