-
Notifications
You must be signed in to change notification settings - Fork 21
[POP-2659] Propagate 2D anonymized bucket statistics from actor to server and SNS #1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
7b1d5ce
e8c9da1
9425683
28980fc
5f23fae
eac405a
2b6a23a
87bb9eb
82743cc
aab045f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ use chrono::{ | |||||||
| use serde::{Deserialize, Serialize}; | ||||||||
| use std::fmt; | ||||||||
|
|
||||||||
| // 1D anonymized statistics types | ||||||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||||||||
| pub struct BucketResult { | ||||||||
| pub count: usize, | ||||||||
|
|
@@ -147,3 +148,127 @@ impl BucketStatistics { | |||||||
| self.next_start_time_utc_timestamp = Some(now_timestamp); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // 2D anonymized statistics types | ||||||||
| #[derive(Debug, Clone, Serialize, Deserialize)] | ||||||||
| pub struct Bucket2DResult { | ||||||||
| pub count: usize, | ||||||||
| pub left_hamming_distance_bucket: [f64; 2], | ||||||||
| pub right_hamming_distance_bucket: [f64; 2], | ||||||||
| } | ||||||||
|
|
||||||||
| impl Eq for Bucket2DResult {} | ||||||||
| impl PartialEq for Bucket2DResult { | ||||||||
| fn eq(&self, other: &Self) -> bool { | ||||||||
| self.count == other.count | ||||||||
| && (self.left_hamming_distance_bucket[0] - other.left_hamming_distance_bucket[0]).abs() | ||||||||
| <= 1e-9 | ||||||||
| && (self.left_hamming_distance_bucket[1] - other.left_hamming_distance_bucket[1]).abs() | ||||||||
| <= 1e-9 | ||||||||
| && (self.right_hamming_distance_bucket[0] - other.right_hamming_distance_bucket[0]) | ||||||||
| .abs() | ||||||||
| <= 1e-9 | ||||||||
| && (self.right_hamming_distance_bucket[1] - other.right_hamming_distance_bucket[1]) | ||||||||
| .abs() | ||||||||
| <= 1e-9 | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] | ||||||||
| pub struct BucketStatistics2D { | ||||||||
| pub buckets: Vec<Bucket2DResult>, | ||||||||
| pub n_buckets_per_side: usize, | ||||||||
| // The number of two-sided matches gathered before sending the statistics | ||||||||
| pub match_distances_buffer_size: usize, | ||||||||
| pub party_id: usize, | ||||||||
| #[serde(with = "ts_seconds")] | ||||||||
| pub start_time_utc_timestamp: DateTime<Utc>, | ||||||||
| #[serde(with = "ts_seconds_option")] | ||||||||
| pub end_time_utc_timestamp: Option<DateTime<Utc>>, | ||||||||
| #[serde(skip_serializing)] | ||||||||
| #[serde(skip_deserializing)] | ||||||||
| #[serde(with = "ts_seconds_option")] | ||||||||
|
Comment on lines
+188
to
+190
|
||||||||
| #[serde(skip_serializing)] | |
| #[serde(skip_deserializing)] | |
| #[serde(with = "ts_seconds_option")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also seems a reasonable suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing
Eqfor a type with floating-point fields violates Rust's equivalence relation requirements. ThePartialEqimplementation uses approximate equality (1e-9 tolerance) which is not transitive, reflexive, or symmetric as required byEq. Remove theEqimplementation and only keepPartialEq.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually true, the
impl Eqshould be removed.