| 140 | aggregatorClass_(std::move(aggregatorClass)) {} |
| 141 | |
| 142 | void PythonAggregate::initializeNewGroups( |
| 143 | char** groups, |
| 144 | folly::Range<const vector_size_t*> indices) { |
| 145 | for (auto i : indices) { |
| 146 | char* group = groups[i]; |
| 147 | |
| 148 | std::unique_ptr<pybind11::object>* pyAggregator = |
| 149 | value<std::unique_ptr<pybind11::object>>(groups[i]); |
| 150 | |
| 151 | // pyAggregator has not been initialized at this point. |
| 152 | // If we try to set its value directly, it will call the |
| 153 | // unique_ptr destructor on the non-initiliazed memory. |
| 154 | // Consequently we need to initialize the bytes to a valid |
| 155 | // temporary value before assigning it. |
| 156 | std::unique_ptr<pybind11::object> nullPtr = nullptr; |
| 157 | std::memcpy(pyAggregator, &nullPtr, sizeof(*pyAggregator)); |
| 158 | |
| 159 | *pyAggregator = |
| 160 | std::make_unique<pybind11::object>(initAggregator(aggregatorClass_)); |
| 161 | clearNull(group); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void PythonAggregate::destroy(folly::Range<char**> groups) { |
| 166 | for (char* group : groups) { |
nothing calls this directly
no test coverage detected