Skip to content

Conversation

JinkunLiu
Copy link
Contributor

@JinkunLiu JinkunLiu commented Sep 20, 2025

What is the purpose of the change

There is a small bug that appendFloat appends 8 bytes, which should be 4 instead. This may cause an ArrayIndexOutOfBoundsException when the buffer doesn't have enough capacity.

The page url is https://issues.apache.org/jira/browse/FLINK-38268

Brief change log

  • FIX BinaryVariantInternalBuilder#appendFloat bug .

Verifying this change

Add a new unit test for FLOAT type. It would fail (throw an exception) without the fix.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: yes
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 20, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

checkCapacity(1 + 4);
writeBuffer[writePos++] = primitiveHeader(FLOAT);
writeLong(writeBuffer, writePos, Float.floatToIntBits(f), 8);
writeLong(writeBuffer, writePos, Float.floatToIntBits(f), 4);
Copy link
Contributor

@davidradl davidradl Sep 22, 2025

Choose a reason for hiding this comment

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

Am I missing something? Long is 8 bytes and it is a writeLong. Could it be that checkCapacity(1 + 4); is incorrect and it should be checkCapacity(1 + 8); Line 286 is a write long with 8 bytes

Copy link
Contributor Author

@JinkunLiu JinkunLiu Sep 22, 2025

Choose a reason for hiding this comment

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

The name of writeLong function might be misleading. The writeLong function does not always write 8 bytes. Its actual functionality is to write Float.floatToIntBits(f) into writeBuffer[writePos, writePos + numBytes). Similarly, you can refer to Line 198

Copy link
Contributor

@davidradl davidradl Sep 23, 2025

Choose a reason for hiding this comment

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

@JinkunLiu ok thanks for the clarification. It agree it is strange/misleading that the method is called writeLong, I would have expected the method to be called writeInt as it seems to have nothing to do with Longs and is writing an Int. Or writeBytes to be more generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hello @Sxnan, What do you think about the name of writeLong function.

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Sep 23, 2025
@JinkunLiu
Copy link
Contributor Author

JinkunLiu commented Sep 23, 2025

hi @twalthr @Sxnan, I have fix this bug and add a new unitTest for appendFloat.

Could you help review those code? If I’ve made any mistakes, please feel free to point them out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-reviewed PR has been reviewed by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants