-
Notifications
You must be signed in to change notification settings - Fork 14.5k
KAFKA-12815: Update JavaDocs of ValueTransformerWithKey #10731
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
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.
@mjsax , thanks for the PR. Left a comment. Thanks.
* <p> | ||
* Note that if a {@code ValueTransformerWithKey} is used in a {@link KTable#transformValues(ValueTransformerWithKeySupplier, String...)} | ||
* (or any other overload of {@code KTable#transformValues(...)}) operation, | ||
* that the provided {@link ProcessorContext} from {@link #init(ProcessorContext)} |
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.
is this a typo?
if a 'xxx' is used in a 'yyy' operation, that the provided 'zzz' from 'aaa' doesn't guarantee....
Maybe replace that
into then
?
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, @mjsax ! What do you think about actually specifying what happens when these things are "not available"?
* does not guarantee that all context information will be available when {@code transform()} | ||
* is executed. |
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.
We might as well formally specify which things may be missing. Otherwise, it's not clear what users should do to guard their code.
* does not guarantee that all context information will be available when {@code transform()} | |
* is executed. | |
* does not guarantee that all record context information will be available when | |
* {@code transform()} is executed. For example, {@code transform()} may be | |
* invoked as a result of upstream punctuations or other out-of-band operations, | |
* in which case there will be no headers, topic name, timestamp, or offset available. | |
* When those properties are absent, the following placeholder values will | |
* be filled in: empty headers, `null` topic name, `-1` timestamp, and `-1` offset. | |
* Implementations of this interface should guard against this case. |
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.
Well, for KTable#transformValues
those things don't apply because there is no out-of-band transformation upstream.
It's the DSL, not the PAPI. It might might sense to add this information in general, but seems to be out-of-scope for this PR?
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.
All I was trying to do was characterize why the context information might be missing. If there are no out-of-band operations, then there should never be missing context.
// we move to `RecordMetadata` than would be `null` for this case and thus | ||
// we won't have the partition information, so it's better to now provide it | ||
// here either, to not introduce a regression later on | ||
-1, |
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.
@vvcephei I think it's better to change this...
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.
Good point, @mjsax .
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.
SGTM, thanks @mjsax to bring to our attention.
* then the provided {@link ProcessorContext} from {@link #init(ProcessorContext)} | ||
* does not guarantee that all context information will be available when {@code transform()} | ||
* is executed, as it might be executed "out-of-band" due to some internal optimizations | ||
* applied by the Kafka Streams DSL. |
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.
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!
Follow up to #10720