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

Method initializeNewGroups

bolt/python/Aggregate.cpp:142–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140 aggregatorClass_(std::move(aggregatorClass)) {}
141
142void 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
165void PythonAggregate::destroy(folly::Range<char**> groups) {
166 for (char* group : groups) {

Callers

nothing calls this directly

Calls 3

memcpyFunction · 0.85
initAggregatorFunction · 0.85
clearNullFunction · 0.85

Tested by

no test coverage detected