-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[FLINK-31708][API / Type Serialization System] make DataInputView#read(byte[], int, int) return 0 if len is 0. #22335
Conversation
…d(byte[], int, int) return 0 if len is 0.
Thanks for the contribution @Shenjiaqi . This PR LGTM. And I think unifying the behavior of implementations of DataInputView#read is a great idea. Would you like take another look @gaoyunhaii ? |
flink-core/src/test/java/org/apache/flink/core/memory/DataInputDeserializerTest.java
Outdated
Show resolved
Hide resolved
flink-core/src/test/java/org/apache/flink/core/memory/DataInputDeserializerTest.java
Outdated
Show resolved
Hide resolved
Thanks @Shenjiaqi for the PR and @pltbkd for the review! I have two minor comments. |
Thanks @gaoyunhaii for review. Now code is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Shenjiaqi for the changes! LGTM
…byte[], int, int) return 0 if len is 0. This closes #22335.
…byte[], int, int) return 0 if len is 0. This closes #22335.
…byte[], int, int) return 0 if len is 0. This closes apache#22335.
What is the purpose of the change
Refine semantic of
DataInputView#read(byte[] b, int off, int len)
interface when len is 0 and no more data is available.There are 4 Classes that implement this method, and their hehavior is different when len is 0 and no more data is available:
There is a chance that when deserializing an protobuf generated empty object,
DataInputDeserializer#read(byte[],int,int)
would return -1, and then cause job failure. (Detail is posted in issue)The reason cause this problem is much like: #20860.
I think the interface should be clarified, and we can use the same semantic as InputStream:
Brief change log
DataInputView#read(byte[] byte, int off, int len)
and clarify behavior when len == 0 and no more data available.DataInputDeserializer#read(byte[] byte, int off, int len)
return 0 if len == 0 and no more data available.InternalDeSerializer#read(byte[] byte, int off, int len)
return 0 if len == 0 and no more data available.Verifying this change
This change added tests and can be verified as follows:
DataInputDeserializer#read
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation