Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misuse of Integer.SIZE in FileWriteOutBytes.writeInt #9723

Merged
merged 2 commits into from
Apr 19, 2020

Conversation

whutjs
Copy link
Contributor

@whutjs whutjs commented Apr 18, 2020

Description

In the FileWriteOutBytes#writeInt(int) method, the argument passed to flushIfNeeded() is Integer.SIZE while the Integer.BYTES should be used.

Problem
This bug will incur one extra file write operation in some cases. For example, if we would like to write 4 KB of ints using FileWriteOutBytes#writeInt(int), the flush() method will be called twice. After fixing this bug, the flush() method will be called only one.


This PR has:

  • been self-reviewed.
  • added unit tests or modified existing tests to cover new code paths.

Key changed/added classes in this PR
  • FileWriteOutBytes
  • FileWriteOutBytesTest

Copy link
Member

@asdf2014 asdf2014 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@asdf2014
Copy link
Member

@whutjs Please add a ASF license header to pass the CI.

@viongpanzi
Copy link
Contributor

viongpanzi commented Apr 18, 2020

We found this problem too and fix it in the pr #9722. After this pr is merged, I will change my commit.

@asdf2014 asdf2014 merged commit b9ad250 into apache:master Apr 19, 2020
@jihoonson jihoonson added this to the 0.18.1 milestone Apr 21, 2020
clintropolis pushed a commit to clintropolis/druid that referenced this pull request Apr 22, 2020
* change Integer.SIZE to Integer.BYTES in FileWriteOutBytes#writeInt

* Add ASF header

Co-authored-by: jenson <junstan@paypal.com>
jihoonson pushed a commit that referenced this pull request Apr 24, 2020
* change Integer.SIZE to Integer.BYTES in FileWriteOutBytes#writeInt

* Add ASF header

Co-authored-by: jenson <junstan@paypal.com>

Co-authored-by: Jenson <whutjs@gmail.com>
Co-authored-by: jenson <junstan@paypal.com>
JulianJaffePinterest pushed a commit to JulianJaffePinterest/druid that referenced this pull request Jun 12, 2020
* change Integer.SIZE to Integer.BYTES in FileWriteOutBytes#writeInt

* Add ASF header

Co-authored-by: jenson <junstan@paypal.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants