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

Method Export

cpp/src/arrow/c/bridge.cc:577–635  ·  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 // Store buffer pointers
583 size_t n_buffers = data->buffers.size();
584 auto buffers_begin = data->buffers.begin();
585 if (n_buffers > 0 && !internal::may_have_validity_bitmap(data->type->id())) {
586 --n_buffers;
587 ++buffers_begin;
588 }
589
590 bool need_variadic_buffer_sizes = data->type->storage_id() == Type::BINARY_VIEW ||
591 data->type->storage_id() == Type::STRING_VIEW;
592 if (need_variadic_buffer_sizes) {
593 ++n_buffers;
594 }
595
596 export_.buffers_.resize(n_buffers);
597 std::transform(buffers_begin, data->buffers.end(), export_.buffers_.begin(),
598 [this](const std::shared_ptr<Buffer>& buffer) -> const void* {
599 return buffer
600 ? (device_interface_
601 ? reinterpret_cast<const void*>(buffer->address())
602 : buffer->data())
603 : nullptr;
604 });
605
606 if (need_variadic_buffer_sizes) {
607 auto variadic_buffers = std::span(data->buffers).subspan(2);
608 export_.variadic_buffer_sizes_.resize(variadic_buffers.size());
609 size_t i = 0;
610 for (const auto& buf : variadic_buffers) {
611 export_.variadic_buffer_sizes_[i++] = buf->size();
612 }
613 export_.buffers_.back() = export_.variadic_buffer_sizes_.data();
614 }
615
616 // Export dictionary
617 if (data->dictionary != nullptr) {
618 dict_exporter_ = std::make_unique<ArrayExporter>(device_interface_);
619 RETURN_NOT_OK(dict_exporter_->Export(data->dictionary));
620 }
621
622 // Export children
623 export_.children_.resize(data->child_data.size());
624 child_exporters_.reserve(data->child_data.size());
625 for (const auto& child : data->child_data) {
626 child_exporters_.emplace_back(ArrayExporter{device_interface_});
627 RETURN_NOT_OK(child_exporters_.back().Export(child));
628 }
629
630 // Store owning pointer to ArrayData
631 export_.data_ = data;
632
633 export_.sync_ = nullptr;
634 return Status::OK();

Callers 4

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

Calls 13

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

Tested by

no test coverage detected