| 836 | } |
| 837 | |
| 838 | SparseUnionScalar::SparseUnionScalar(ValueType value, int8_t type_code, |
| 839 | std::shared_ptr<DataType> type) |
| 840 | : UnionScalar(std::move(type), type_code, /*is_valid=*/true), |
| 841 | ArraySpanFillFromScalarScratchSpace(type_code), |
| 842 | value(std::move(value)) { |
| 843 | const auto child_ids = checked_cast<const SparseUnionType&>(*this->type).child_ids(); |
| 844 | if (type_code >= 0 && static_cast<size_t>(type_code) < child_ids.size() && |
| 845 | child_ids[type_code] != UnionType::kInvalidChildId) { |
| 846 | this->child_id = child_ids[type_code]; |
| 847 | |
| 848 | // Fix nullness based on whether the selected child is null |
| 849 | this->is_valid = this->value[this->child_id]->is_valid; |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | std::shared_ptr<Scalar> SparseUnionScalar::FromValue(std::shared_ptr<Scalar> value, |
| 854 | int field_index, |