Skip to content

[BEAM-409] Fixing incorrect use of Math.ceil in ApproximateQuantiles#3861

Closed
youngoli wants to merge 3 commits intoapache:masterfrom
youngoli:bugfix-beam409
Closed

[BEAM-409] Fixing incorrect use of Math.ceil in ApproximateQuantiles#3861
youngoli wants to merge 3 commits intoapache:masterfrom
youngoli:bugfix-beam409

Conversation

@youngoli
Copy link
Contributor

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

Fixed the FindBug issue by avoiding an incorrect integer division. I based this on an old unmerged pull request for this bug: #853

That PR also included a new unit test for ApproximateQuantiles.java, wasn't sure if I should also include that unit test.

Casting the denominator in this division in the ceil call to a float to
avoid an incorrect integer division causing a bug.
@swegner
Copy link
Contributor

swegner commented Sep 19, 2017

Thanks for this contribution. Please also include a unit test to verify. The unmerged PR #853 had a couple new tests, testEfficiency() and testCorrectness(), and just needed some slight changes to use JUnit @Parameters. See: https://github.com/apache/beam/pull/853/files#r75763207

Adding unit tests written by swegner to confirm that the bug was fixed.
@youngoli
Copy link
Contributor Author

Thanks swegner. I added in the unit tests you made for PR #853 and added the @Parameters change.

@swegner
Copy link
Contributor

swegner commented Sep 20, 2017

retest this please

1 similar comment
@swegner
Copy link
Contributor

swegner commented Sep 21, 2017

retest this please

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1875004 on youngoli:bugfix-beam409 into ** on apache:master**.

@swegner
Copy link
Contributor

swegner commented Sep 21, 2017

LGTM. Adding @tgroh as Beam committer to merge.

Copy link
Member

@tgroh tgroh left a comment

Choose a reason for hiding this comment

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

Single nit, then will merge

long n = this.maxInputSize;

assertTrue("(b-2)2^(b-2) + 1/2 <= eN", (b - 2) * (1 << (b - 2)) + 0.5 <= this.epsilon * n);
assertTrue("k2^(b-1) >= N", Math.pow(k * 2, b - 1) >= n);
Copy link
Member

Choose a reason for hiding this comment

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

assertThat("what", actual, Matchers.lessThanOrEqualTo(expected)) and the same with the greater than or equal to.

Changing calls to assertTrue to assertThat.
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8362ca3 on youngoli:bugfix-beam409 into ** on apache:master**.

@youngoli
Copy link
Contributor Author

retest this please

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8362ca3 on youngoli:bugfix-beam409 into ** on apache:master**.

@youngoli
Copy link
Contributor Author

retest this please

1 similar comment
@youngoli
Copy link
Contributor Author

retest this please

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8362ca3 on youngoli:bugfix-beam409 into ** on apache:master**.

@asfgit asfgit closed this in 52ad6f1 Oct 17, 2017
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