MCPcopy Create free account
hub / github.com/bytedance/bolt / setValueAt

Function setValueAt

bolt/python/Aggregate.cpp:98–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97template <TypeKind TYPE>
98void 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
135namespace bolt::python {

Callers

nothing calls this directly

Calls 5

pyInstanceTypeStrFunction · 0.85
mapTypeKindToNameFunction · 0.85
copyMethod · 0.45
sliceMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected