MCPcopy Create free account
hub / github.com/apache/arrow / MergeInput

Method MergeInput

cpp/src/arrow/util/tdigest.cc:244–272  ·  view source on GitHub ↗

merge input data with current tdigest

Source from the content-addressed store, hash-verified

242
243 // merge input data with current tdigest
244 void MergeInput(std::vector<double>& input) {
245 total_weight_ += input.size();
246
247 std::sort(input.begin(), input.end());
248 min_ = std::min(min_, input.front());
249 max_ = std::max(max_, input.back());
250
251 // pick next minimal centroid from input and tdigest, feed to merger
252 merger_.Reset(total_weight_, &tdigests_[1 - current_]);
253 const auto& td = tdigests_[current_];
254 uint32_t tdigest_index = 0, input_index = 0;
255 while (tdigest_index < td.size() && input_index < input.size()) {
256 if (td[tdigest_index].mean < input[input_index]) {
257 merger_.Add(td[tdigest_index++]);
258 } else {
259 merger_.Add(Centroid{input[input_index++], 1});
260 }
261 }
262 while (tdigest_index < td.size()) {
263 merger_.Add(td[tdigest_index++]);
264 }
265 while (input_index < input.size()) {
266 merger_.Add(Centroid{input[input_index++], 1});
267 }
268 merger_.Reset(0, nullptr);
269
270 input.resize(0);
271 current_ = 1 - current_;
272 }
273
274 double Quantile(double q) const {
275 const auto& td = tdigests_[current_];

Callers

nothing calls this directly

Calls 7

backMethod · 0.80
resizeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ResetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected