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