Skip to content

Fix division by zero in approximate facet API, shortcut instead - #5551

Merged
timvisee merged 1 commit into
devfrom
facet-prevent-division-by-zero
Nov 29, 2024
Merged

timvisee merged 1 commit into
devfrom
facet-prevent-division-by-zero

Conversation

@timvisee

@timvisee timvisee commented Nov 29, 2024 •

Copy link
Copy Markdown
Member

Adjust the approximate facet interface to prevent a division by zero.

If a segment is empty, this will become infinite:

let percentage_filtered = filter_cardinality.exp as f64 / available_points as f64;

After which this is incorrectly (?) false:

let use_iterative_approach = percentage_filtered < 0.3;

I've adjusted this function to simply shortcut if the segment is empty. In that case there are no facet values to consider anyway. That also prevents the above problem.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

@timvisee
timvisee requested a review from coszio November 29, 2024 10:14

@coszio coszio left a comment

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.

Good catch! I thought I had already faced this problem here before. Thought it was already handled.

Thanks for the fix.

@timvisee
timvisee merged commit ba61ae2 into dev Nov 29, 2024
@timvisee
timvisee deleted the facet-prevent-division-by-zero branch November 29, 2024 13:52
@timvisee timvisee mentioned this pull request Dec 9, 2024
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