| 117 | : PrimitiveConverter(pool, type), numeric_type_(checked_cast<const T&>(*type)) {} |
| 118 | |
| 119 | Status Convert(const std::shared_ptr<Array>& in, std::shared_ptr<Array>* out) override { |
| 120 | if (in->type_id() == Type::NA) { |
| 121 | return MakeArrayOfNull(out_type_, in->length(), pool_).Value(out); |
| 122 | } |
| 123 | const auto& dict_array = GetDictionaryArray(in); |
| 124 | |
| 125 | using Builder = typename TypeTraits<T>::BuilderType; |
| 126 | Builder builder(out_type_, pool_); |
| 127 | RETURN_NOT_OK(builder.Resize(dict_array.indices()->length())); |
| 128 | |
| 129 | auto visit_valid = [&](string_view repr) { |
| 130 | value_type value; |
| 131 | if (!arrow::internal::ParseValue(numeric_type_, repr.data(), repr.size(), &value)) { |
| 132 | return GenericConversionError(*out_type_, ", couldn't parse:", repr); |
| 133 | } |
| 134 | |
| 135 | builder.UnsafeAppend(value); |
| 136 | return Status::OK(); |
| 137 | }; |
| 138 | |
| 139 | auto visit_null = [&]() { |
| 140 | builder.UnsafeAppendNull(); |
| 141 | return Status::OK(); |
| 142 | }; |
| 143 | |
| 144 | RETURN_NOT_OK(VisitDictionaryEntries(dict_array, visit_valid, visit_null)); |
| 145 | return builder.Finish(out); |
| 146 | } |
| 147 | |
| 148 | const T& numeric_type_; |
| 149 | }; |
nothing calls this directly
no test coverage detected