| 96 | |
| 97 | template <TypeKind TYPE> |
| 98 | void setValueAt( |
| 99 | BaseVector& v, |
| 100 | const vector_size_t i, |
| 101 | const pybind11::object& pyVal) { |
| 102 | bolt::python::pyTry<void>( |
| 103 | [&]() { |
| 104 | if constexpr (TYPE == TypeKind::ROW) { |
| 105 | auto rhs = pyVal.cast<RowVectorPtr>(); |
| 106 | v.slice(i, 1)->copy(*rhs); |
| 107 | } |
| 108 | if constexpr (TYPE == TypeKind::MAP) { |
| 109 | auto rhs = pyVal.cast<std::shared_ptr<MapVector>>(); |
| 110 | v.slice(i, 1)->copy(*rhs); |
| 111 | } |
| 112 | if constexpr (TYPE == TypeKind::ARRAY) { |
| 113 | auto rhs = pyVal.cast<std::shared_ptr<ArrayVector>>(); |
| 114 | v.slice(i, 1)->copy(*rhs); |
| 115 | } |
| 116 | if constexpr ( |
| 117 | TYPE != TypeKind::ROW && TYPE != TypeKind::MAP && |
| 118 | TYPE != TypeKind::ARRAY) { |
| 119 | auto cppVal = pyVal.cast<typename TypeTraits<TYPE>::DeepCopiedType>(); |
| 120 | auto* vec = v.as<FlatVector<decltype(cppVal)>>(); |
| 121 | BOLT_CHECK(vec != nullptr); |
| 122 | vec->set(i, std::move(cppVal)); |
| 123 | } |
| 124 | }, |
| 125 | [&]() { |
| 126 | return fmt::format( |
| 127 | "Invalid or unsupported cast of python aggregation function" |
| 128 | "result type '{}' to the cpp type: '{}'.", |
| 129 | bolt::python::pyInstanceTypeStr(pyVal), |
| 130 | mapTypeKindToName(TYPE)); |
| 131 | }); |
| 132 | } |
| 133 | } // namespace |
| 134 | |
| 135 | namespace bolt::python { |
nothing calls this directly
no test coverage detected