| 851 | } |
| 852 | |
| 853 | std::shared_ptr<Scalar> SparseUnionScalar::FromValue(std::shared_ptr<Scalar> value, |
| 854 | int field_index, |
| 855 | std::shared_ptr<DataType> type) { |
| 856 | const auto& union_type = checked_cast<const SparseUnionType&>(*type); |
| 857 | int8_t type_code = union_type.type_codes()[field_index]; |
| 858 | ScalarVector field_values; |
| 859 | for (int i = 0; i < type->num_fields(); ++i) { |
| 860 | if (i == field_index) { |
| 861 | field_values.emplace_back(std::move(value)); |
| 862 | } else { |
| 863 | field_values.emplace_back(MakeNullScalar(type->field(i)->type())); |
| 864 | } |
| 865 | } |
| 866 | return std::make_shared<SparseUnionScalar>(field_values, type_code, std::move(type)); |
| 867 | } |
| 868 | |
| 869 | void SparseUnionScalar::FillScratchSpace(uint8_t* scratch_space, int8_t type_code) { |
| 870 | auto* union_scratch_space = reinterpret_cast<UnionScratchSpace*>(scratch_space); |
nothing calls this directly
no test coverage detected