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

Method Add

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

merge one centroid from a sorted centroid stream

Source from the content-addressed store, hash-verified

88
89 // merge one centroid from a sorted centroid stream
90 void Add(const Centroid& centroid) {
91 auto& td = *tdigest_;
92 const double weight = weight_so_far_ + centroid.weight;
93 if (weight <= weight_limit_) {
94 td.back().Merge(centroid);
95 } else {
96 const double quantile = weight_so_far_ / total_weight_;
97 const double next_weight_limit = total_weight_ * this->Q(this->K(quantile) + 1);
98 // weight limit should be strictly increasing, until the last centroid
99 if (next_weight_limit <= weight_limit_) {
100 weight_limit_ = total_weight_;
101 } else {
102 weight_limit_ = next_weight_limit;
103 }
104 td.push_back(centroid); // should never exceed capacity and trigger reallocation
105 }
106 weight_so_far_ = weight;
107 }
108
109 // validate k-size of a tdigest
110 Status Validate(const std::vector<Centroid>& tdigest, double total_weight) const {

Callers 9

AddLatencyMethod · 0.45
TESTFunction · 0.45
TestRandomFunction · 0.45
TestMergeFunction · 0.45
BenchmarkTDigestFunction · 0.45
MergeMethod · 0.45
MergeInputMethod · 0.45
CanonicalizeFunction · 0.45

Calls 5

backMethod · 0.80
push_backMethod · 0.80
MergeMethod · 0.45
QMethod · 0.45
KMethod · 0.45

Tested by 3

TESTFunction · 0.36
TestRandomFunction · 0.36
TestMergeFunction · 0.36