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

Method Finish

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

Finalize exporting by setting C struct fields and allocating autonomous private data for each array node. This function can't fail, as properly reclaiming memory in case of error would be too fragile. After this function returns, memory is reclaimed by calling the release() pointer in the top level ArrowArray struct.

Source from the content-addressed store, hash-verified

641 // would be too fragile. After this function returns, memory is reclaimed
642 // by calling the release() pointer in the top level ArrowArray struct.
643 void Finish(struct ArrowArray* c_struct_) {
644 // First, create permanent ExportedArrayPrivateData, to make sure that
645 // child ArrayData pointers don't get invalidated.
646 auto pdata = new ExportedArrayPrivateData(std::move(export_));
647 const ArrayData& data = *pdata->data_;
648
649 // Second, finish dictionary and children.
650 if (dict_exporter_) {
651 dict_exporter_->Finish(&pdata->dictionary_);
652 }
653 pdata->child_pointers_.resize(data.child_data.size(), nullptr);
654 for (size_t i = 0; i < data.child_data.size(); ++i) {
655 auto ptr = &pdata->children_[i];
656 pdata->child_pointers_[i] = ptr;
657 child_exporters_[i].Finish(ptr);
658 }
659
660 // Third, fill C struct.
661 DCHECK_NE(c_struct_, nullptr);
662 memset(c_struct_, 0, sizeof(*c_struct_));
663
664 c_struct_->length = data.length;
665 c_struct_->null_count = data.null_count;
666 c_struct_->offset = data.offset;
667 c_struct_->n_buffers = static_cast<int64_t>(pdata->buffers_.size());
668 c_struct_->n_children = static_cast<int64_t>(pdata->child_pointers_.size());
669 c_struct_->buffers = pdata->buffers_.data();
670 c_struct_->children = c_struct_->n_children ? pdata->child_pointers_.data() : nullptr;
671 c_struct_->dictionary = dict_exporter_ ? &pdata->dictionary_ : nullptr;
672 c_struct_->private_data = pdata;
673 c_struct_->release = ReleaseExportedArray;
674 }
675
676 ExportedArrayPrivateData export_;
677 std::unique_ptr<ArrayExporter> dict_exporter_;

Callers 8

FinishMethod · 0.45
ExportTypeFunction · 0.45
ExportFieldFunction · 0.45
ExportSchemaFunction · 0.45
ExportArrayFunction · 0.45
ExportRecordBatchFunction · 0.45
ExportDeviceArrayFunction · 0.45
ExportDeviceRecordBatchFunction · 0.45

Calls 3

resizeMethod · 0.80
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected