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

Method DoImport

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

Source from the content-addressed store, hash-verified

1600 }
1601
1602 Status DoImport() {
1603 // Unwrap extension type
1604 const DataType* storage_type = type_.get();
1605 if (storage_type->id() == Type::EXTENSION) {
1606 storage_type =
1607 checked_cast<const ExtensionType&>(*storage_type).storage_type().get();
1608 }
1609
1610 // First import children (required for reconstituting parent array data)
1611 const auto& fields = storage_type->fields();
1612 if (c_struct_->n_children != static_cast<int64_t>(fields.size())) {
1613 return Status::Invalid("ArrowArray struct has ", c_struct_->n_children,
1614 " children, expected ", fields.size(), " for type ",
1615 type_->ToString());
1616 }
1617 child_importers_.reserve(fields.size());
1618 for (int64_t i = 0; i < c_struct_->n_children; ++i) {
1619 DCHECK_NE(c_struct_->children[i], nullptr);
1620 child_importers_.emplace_back(fields[i]->type());
1621 RETURN_NOT_OK(child_importers_.back().ImportChild(this, c_struct_->children[i]));
1622 }
1623
1624 // Import main data
1625 RETURN_NOT_OK(VisitTypeInline(*storage_type, this));
1626
1627 bool is_dict_type = (storage_type->id() == Type::DICTIONARY);
1628 if (c_struct_->dictionary != nullptr) {
1629 if (!is_dict_type) {
1630 return Status::Invalid("Import type is ", type_->ToString(),
1631 " but dictionary field in ArrowArray struct is not null");
1632 }
1633 const auto& dict_type = checked_cast<const DictionaryType&>(*storage_type);
1634 // Import dictionary values
1635 ArrayImporter dict_importer(dict_type.value_type());
1636 RETURN_NOT_OK(dict_importer.ImportDict(this, c_struct_->dictionary));
1637 data_->dictionary = dict_importer.GetArrayData();
1638 } else {
1639 if (is_dict_type) {
1640 return Status::Invalid("Import type is ", type_->ToString(),
1641 " but dictionary field in ArrowArray struct is null");
1642 }
1643 }
1644 return Status::OK();
1645 }
1646
1647 Status Visit(const DataType& type) {
1648 return Status::NotImplemented("Cannot import array of type ", type_->ToString());

Callers

nothing calls this directly

Calls 15

VisitTypeInlineFunction · 0.85
storage_typeMethod · 0.80
emplace_backMethod · 0.80
backMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
getMethod · 0.45
idMethod · 0.45
fieldsMethod · 0.45
sizeMethod · 0.45
ToStringMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected