Skip to content

fix: respect negative values on deserialization in REQ sketch#734

Open
proost wants to merge 3 commits into
apache:mainfrom
proost:fix-respect-negative-values
Open

fix: respect negative values on deserialization in REQ sketch#734
proost wants to merge 3 commits into
apache:mainfrom
proost:fix-respect-negative-values

Conversation

@proost
Copy link
Copy Markdown
Member

@proost proost commented Apr 25, 2026

Float.MIN_VALUE is smallest positive value. So if REQ sketch include negative values, min value is not respected after deserialization.

C++ is ok, because it delegates to comparator not like java.

After this PR merged, I will send PR for compat in C++.

@proost proost requested a review from leerho April 25, 2026 08:20
@proost proost self-assigned this Apr 25, 2026
Copy link
Copy Markdown
Member

@leerho leerho left a comment

Choose a reason for hiding this comment

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

See comment in the code.

posSeg.getFloatArray(arr, 0, count);
float minItem = Float.MAX_VALUE;
float maxItem = Float.MIN_VALUE;
float maxItem = -Float.MAX_VALUE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What you found here is obviously incorrect, but neither is your solution. Internally, for the Classic Quantiles, KLL and REQ, the min and max values are initialized to NaN. and the first incoming value that is not NaN, sets both the min and max values. This allows input values of +/- infinity, which your solution would not recognize. I would argue that you should use a similar solution here, for consistency if nothing else.

I would also suggest you create a test that uses +/- Infinities, just to confirm that it works.

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.

2 participants