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

Method DoImport

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

Source from the content-addressed store, hash-verified

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