-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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-37383][flink-examples]Correct throttling logic on ThrottledIterator #26203
base: master
Are you sure you want to change the base?
[FLINK-37383][flink-examples]Correct throttling logic on ThrottledIterator #26203
Conversation
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.
Please add unit tests
8f82f6e
to
600c9c2
Compare
Adding tests would require refactoring the time-dependent code, which might increase complexity for what's meant to be just an example class. Would you prefer to keep the implementation simple, or should I proceed with the refactoring? |
892cd0a
to
3bf85ee
Compare
Tests added |
c1cfd9d
to
f9edfd3
Compare
@flinkbot run azure |
a924f44
to
d772d70
Compare
The throttle function was updating its last batch check time before the sleep operation, causing it to underestimate the elapsed time and allow approximately double the intended throughput rate. Moving the timestamp update to after the sleep ensures the elapsed time calculation properly accounts for the full duration between batches, maintaining the configured rate limit. The commit refactors ThrottledIterator by: Adding injectable time supplier and sleep function for better testing Improving code maintainability with functional interfaces This change makes the code more testable and reliable while maintaining existing functionality. Add test coverage for ThrottledIterator edge cases Adds test coverage for invalid elements per second, consistent window size, and non-serializable source scenarios in ThrottledIterator tests.
d772d70
to
422a59d
Compare
@flinkbot run azure |
@davidradl The PR is ready for another review round. |
What is the purpose of the change
The throttle function was updating its last batch check time before the sleep operation, causing it to underestimate the elapsed time and allow approximately double the intended throughput rate.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation