ariesdevil commented on code in PR #231:
URL: https://github.com/apache/datasketches-rust/pull/231#discussion_r3868517321
##########
datasketches/src/tdigest/sketch.rs:
##########
@@ -388,6 +388,34 @@ impl TDigestMut {
return;
}
+ let sorted_merge_buffer = match (&mut self.buffer, &other.buffer) {
+ (
+ TDigestBuffer::Staging(values),
+ TDigestBuffer::Centroids {
+ centroids,
+ unmerged_tail_len: 0,
+ },
+ ) if values.is_empty() && centroids_are_sorted(centroids) =>
Some(centroids.clone()),
+ (
+ TDigestBuffer::Centroids {
+ centroids: self_centroids,
+ unmerged_tail_len: 0,
+ },
+ TDigestBuffer::Centroids {
+ centroids: other_centroids,
+ unmerged_tail_len: 0,
+ },
+ ) if centroids_are_sorted(self_centroids) &&
centroids_are_sorted(other_centroids) => {
+ merge_sorted_centroids(self_centroids, other_centroids);
+ Some(std::mem::take(self_centroids))
+ }
+ _ => None,
+ };
Review Comment:
I suggest moving this lengthy pattern matching to an independent function
and adding a brief comment.
--
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]