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

Method Finish

cpp/src/arrow/c/bridge.cc:651–682  ·  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

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