LindaSummer commented on code in PR #2811:
URL: https://github.com/apache/kvrocks/pull/2811#discussion_r1977525005


##########
src/types/redis_tdigest.cc:
##########
@@ -161,6 +161,8 @@ rocksdb::Status TDigest::Add(engine::Context& ctx, const 
Slice& digest_name, con
 
   metadata.total_observations += inputs.size();
   metadata.total_weight += inputs.size();
+  metadata.maximum = std::max(metadata.maximum, 
*std::max_element(inputs.cbegin(), inputs.cend()));

Review Comment:
   Hi @mapleFU ,
   
   Thanks for your update! 😊
   
   Currently the min and max are updated after Merge with `DumpCentroids()`.
   
   But `Add` will not always trigger the Merge action until the buffer is full.
   
   So, if we try to update it in `Add` maybe we'd better remove the [updating 
of min&max after 
`DumpCentroids()`](https://github.com/apache/kvrocks/blob/34007db3a5a74e7c773209a16c6d0a5cc09ef884/src/types/redis_tdigest.cc#L282-L283).
   
   Since when we try to merge, the buffer will always be locked, it is safe to 
update the value either in `Add` or `Merge`.
   
   Best Regards,
   Edward
   



-- 
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]

Reply via email to