Skip to content

MINOR: change initial value of Min stat to Double.MAX_VALUE (not MIN)#1143

Closed
zackdever wants to merge 2 commits into
apache:trunkfrom
zackdever:min-stat-fix
Closed

MINOR: change initial value of Min stat to Double.MAX_VALUE (not MIN)#1143
zackdever wants to merge 2 commits into
apache:trunkfrom
zackdever:min-stat-fix

Conversation

@zackdever
Copy link
Copy Markdown
Contributor

this is consistent with the Max stat implementation.

@auradkar
Copy link
Copy Markdown
Contributor

Seems correct. I think the default value is used to create samples. In this case, the Min function would have reported an incorrect value right? Can you write a test case to prove correctness now?

@zackdever
Copy link
Copy Markdown
Contributor Author

Yes I think it would have. I'll see if there's a relevant max test to keep things similar, or if not I'll write one for both.

@zackdever
Copy link
Copy Markdown
Contributor Author

I updated testOldDataHasNoEffect to include Min, along with a couple other SampledStats. The updated test fails if ran against trunk. I can make a new test if desired, but the flow would be the exact same - the only way initialValue is ever exposed is by measuring a SampledStat with an old Sample that has been reset. If you just measure a new SampledStat without ever calling record, a Sample is never created and initialValue never comes into play. That might be an argument for using initialValue as the default starting value in the implementation of combine, but that seemed like a more substantial (but functionally equivalent) change.

zackdever added a commit to zackdever/kafka-python that referenced this pull request Mar 30, 2016
@dpkp
Copy link
Copy Markdown
Contributor

dpkp commented Mar 31, 2016

+1 !

zackdever added a commit to zackdever/kafka-python that referenced this pull request Apr 1, 2016
zackdever added a commit to zackdever/kafka-python that referenced this pull request Apr 5, 2016
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.

nit: i'd prefer a new testcase. this doesn't really have anything to do with 'testOldDataHasNoEffect'

@auradkar
Copy link
Copy Markdown
Contributor

auradkar commented Apr 5, 2016

+1. minor

zackdever added a commit to zackdever/kafka-python that referenced this pull request Apr 6, 2016
zackdever added a commit to zackdever/kafka-python that referenced this pull request Apr 7, 2016
@zackdever zackdever force-pushed the min-stat-fix branch 3 times, most recently from f308727 to 67b052d Compare April 15, 2016 17:36
@zackdever
Copy link
Copy Markdown
Contributor Author

@auradkar I updated the test, let me know what you think. I think the Jenkins failures are unrelated.

this is consistent with the Max stat implementation. also update
variable names to `min` instead of `max`, and test.
instead of repurposing testOldDataHasNoEffect
@zackdever
Copy link
Copy Markdown
Contributor Author

Jenkins failures were unrelated - rebased master and all is passing now.


public Min() {
super(Double.MIN_VALUE);
super(Double.MAX_VALUE);
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.

Nice catch (and sorry for long delay in review).
I saw we are using NEGATIVE_INFINITY for Max() default. Any reason not to use INFINITY here? It seems more consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries. I noticed that too, and I think it would be more consistent to use INFINITY, but the convention seems to be that the combine implementation uses the same value for the de facto default (even though it doesn't make use of initialValue). Min() is already using Double.MAX_VALUE in combine, so also changing that felt like a bigger change (and possibly unwelcome if users were already handling Double.MAX_VALUE in their metrics tooling).

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.

fair enough. LGTM.

@asfgit asfgit closed this in 94d1878 Apr 29, 2016
gfodor pushed a commit to AltspaceVR/kafka that referenced this pull request Jun 3, 2016
this is consistent with the Max stat implementation.

Author: Zack Dever <zdever@pandora.com>

Reviewers: Aditya Auradkar, Gwen Shapira

Closes apache#1143 from zackdever/min-stat-fix
efeg pushed a commit to efeg/kafka that referenced this pull request May 29, 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.

4 participants