hello-stephen commented on code in PR #70819:
URL: https://github.com/apache/doris/pull/70819#discussion_r4751979274


##########
be/src/core/value/quantile_state.cpp:
##########
@@ -92,9 +97,18 @@ TDigest& QuantileState::_mutable_tdigest() {
     return _tdigest_ptr->digest;
 }
 
-QuantileState::QuantileState() : _type(EMPTY), 
_compression(QUANTILE_STATE_COMPRESSION_MIN) {}
+void QuantileState::_add_to_digest(TDigest& digest, double value) const {
+    const auto sample = static_cast<float>(value);
+    if (_compression < QUANTILE_STATE_COMPRESSION_DEFAULT) {
+        digest.add_preserving_extrema(sample);
+    } else {
+        digest.add(sample);

Review Comment:
   [P2] Preserve raw extrema after promoting a low-compression partial
   
   The high-C branch can lose an endpoint when the new mixed-compression path 
combines weighted centroids with raw samples. For example, build C32 from 33 
copies of `100`, self-merge 17 times, then append `101` without 
querying/serializing it. Merging that partial into a C2048 singleton `102` 
queues `102` here without recording its maximum, while 
`merge_preserving_extrema()` imports only the source maximum `101`. At total 
weight 4,325,378, `_process()` can fold the two pending unit samples into a 
centroid with mean `101.5`, so `quantile_percent(..., 1)` and the serialized 
result lose the actual maximum `102`. Record the incoming raw extrema even 
after compression is promoted, and add a large weighted mixed-compression 
endpoint case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to