Skip to content

f64 counter support#25

Merged
GordonYuanyc merged 7 commits intomainfrom
f64-counter-support
Mar 10, 2026
Merged

f64 counter support#25
GordonYuanyc merged 7 commits intomainfrom
f64-counter-support

Conversation

@GnaneshGnani
Copy link
Copy Markdown
Contributor

As per changes suggested this comment:

We use sketchlib-rust in the ASAP query engine to aggregate floating-point telemetry metrics
(CPU %, request durations, etc.). Because CountMin<Vector2D, RegularPath> requires
S::Counter: Ord, and f64: !Ord (due to NaN), we currently round every metric value to the
nearest i64 before insertion, silently discarding fractional precision (0.7 → 0, 1.3 → 1).

Vector2D already satisfies MatrixStorage (T: Copy + AddAssign). with_dimensions and
from_storage already compile for f64. The only missing piece is insert_many / estimate for
the f64 counter path.

A single impl block for CountMin<Vector2D, RegularPath, H> that adds
insert_weighted(key, f64) and estimate_f64(key) -> f64, using f64::min() instead of the
Ord-dependent .min(). A CountMinF64 type alias is exported for convenience. No existing
API is changed.

@GordonYuanyc
Copy link
Copy Markdown
Collaborator

Please avoid functions like estimate_f64, as we don't want to have estimate_f32 etc.
Please avoid duplication of function that only support one specific type (unless absolutely necessary).
Please consider downgrade the Ord trait to PartialOrd and adjust the estimate function accordingly.
Please also kindly consider the FastPath as well, besides the RegularPath.
Thank you.

@GordonYuanyc GordonYuanyc marked this pull request as draft March 9, 2026 17:38
let v = self.counts.query_one_counter(r, col);
if v.partial_cmp(&min)
.map(|o| o == Ordering::Less)
.unwrap_or(false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Min < v
V < min from Yancheng.

@GordonYuanyc GordonYuanyc marked this pull request as ready for review March 10, 2026 02:55
Copy link
Copy Markdown
Collaborator

@GordonYuanyc GordonYuanyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GordonYuanyc GordonYuanyc merged commit a729288 into main Mar 10, 2026
1 check passed
@GordonYuanyc GordonYuanyc deleted the f64-counter-support branch March 10, 2026 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants