MCPcopy Create free account
hub / github.com/apache/arrow / Export

Method Export

cpp/src/arrow/c/bridge.cc:577–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575 : device_interface_(device_interface) {}
576
577 Status Export(const std::shared_ptr<ArrayData>& data) {
578 // Force computing null count.
579 // This is because ARROW-9037 is in version 0.17 and 0.17.1, and they are
580 // not able to import arrays without a null bitmap and null_count == -1.
581 data->GetNullCount();
582
583 const auto physical_type_id = data->type->storage_id();
584
585 // Store buffer pointers
586 size_t n_buffers = data->buffers.size();
587 auto buffers_begin = data->buffers.begin();
588 if (n_buffers > 0 && !internal::may_have_validity_bitmap(physical_type_id)) {
589 --n_buffers;
590 ++buffers_begin;
591 }
592
593 bool need_variadic_buffer_sizes =
594 physical_type_id == Type::BINARY_VIEW || physical_type_id == Type::STRING_VIEW;
595 if (need_variadic_buffer_sizes) {
596 ++n_buffers;
597 }
598
599 export_.buffers_.resize(n_buffers);
600 std::transform(buffers_begin, data->buffers.end(), export_.buffers_.begin(),
601 [this](const std::shared_ptr<Buffer>& buffer) -> const void* {
602 return buffer
603 ? (device_interface_
604 ? reinterpret_cast<const void*>(buffer->address())
605 : buffer->data())
606 : nullptr;
607 });
608
609 if (need_variadic_buffer_sizes) {
610 auto variadic_buffers = std::span(data->buffers).subspan(2);
611 export_.variadic_buffer_sizes_.resize(variadic_buffers.size());
612 size_t i = 0;
613 for (const auto& buf : variadic_buffers) {
614 if (buf == nullptr) {
615 return Status::Invalid("Cannot export array of type ", data->type->ToString(),
616 ": null variadic buffer at buffer index #", i + 2,
617 " (variadic buffer index #", i, ")");
618 }
619 export_.variadic_buffer_sizes_[i++] = buf->size();
620 }
621 export_.buffers_.back() = export_.variadic_buffer_sizes_.data();
622 }
623
624 // Export dictionary
625 if (data->dictionary != nullptr) {
626 dict_exporter_ = std::make_unique<ArrayExporter>(device_interface_);
627 RETURN_NOT_OK(dict_exporter_->Export(data->dictionary));
628 }
629
630 // Export children
631 export_.children_.resize(data->child_data.size());
632 child_exporters_.reserve(data->child_data.size());
633 for (const auto& child : data->child_data) {
634 child_exporters_.emplace_back(ArrayExporter{device_interface_});

Callers 4

ExportArrayFunction · 0.45
ExportRecordBatchFunction · 0.45
ExportDeviceArrayFunction · 0.45
ExportDeviceRecordBatchFunction · 0.45

Calls 14

may_have_validity_bitmapFunction · 0.85
GetNullCountMethod · 0.80
resizeMethod · 0.80
addressMethod · 0.80
backMethod · 0.80
emplace_backMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected