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
KAFKA-4218: Add withkey methods to KGroupedTable #3601
Conversation
Add withkey interfaces Add withKey converters in AbstractStream Add withKey interface to KGroupedTable Remove unnecessary lines Remove unnecessary lines
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
@bbejeck @mjsax @enothereska @guozhangwang reviews please |
|
||
/** | ||
* The {@code InitializerWithKey} interface for creating an initial value in aggregations with read-only key. | ||
* Note that provided keys are read-only and should not be modified. Any key modification can result in corrupt |
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.
nit: the provided
* For sum, the adder and substractor would work as follows: | ||
* <pre>{@code | ||
* public class SumAdder implements ReducerWithKey<Integer, Integer> { | ||
* public Integer apply(Integer key, Integer currentAgg, Integer newValue) { |
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.
Should this example show the key
being used somehow?
* } | ||
* | ||
* public class SumSubtractor implements ReducerWithKey<Integer, Integer> { | ||
* public Integer apply(Integer key, Integer currentAgg, Integer oldValue) { |
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.
Same as above
* public Integer apply(Integer currentAgg, Integer oldValue) { | ||
* return currentAgg - oldValue; | ||
* public class SumSubtractor implements ReducerWithKey<Integer, Integer> { | ||
* public Integer apply(Integer currentAgg, Integer oldValue) { |
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 the ReducerWithKey#apply
impl here missing the Integer key
parameter?
* For sum, the adder and substractor would work as follows: | ||
* <pre>{@code | ||
* public class SumAdder implements ReducerWithKey<Integer, Integer> { | ||
* public Integer apply(Integer key, Integer currentAgg, Integer newValue) { |
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.
Ditto from above, should we have an example using the key
? The same for the rest of the javadoc code examples.
|
||
/** | ||
* Aggregate the value of records of the original {@link KTable} that got {@link KTable#groupBy(KeyValueMapper) | ||
* mapped} to the same key into a new instance of {@link KTable} using default serializers and deserializers. | ||
* Records with {@code null} key are ignored. | ||
* Aggregating is a generalization of {@link #reduce(Reducer, Reducer, String) combining via reduce(...)} as it, | ||
* for example, allows the result to have a different type than the input values. | ||
* If the result value type does not match the {@link StreamsConfig#DEFAULT_VALUE_SERDE_CLASS_CONFIG default value | ||
* If the result value type does not match the {@link StreamsConfig#VALUE_SERDE_CLASS_CONFIG default value |
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.
Was this intentional? VALUE_SERDE_CLASS_CONFIG
is deprecated.
Thanks @jeyhunkarimov for the work and multiple PRs. I've made an initial pass. Two things so far:
EDIT: can you rebase as well? thanks. |
This PR aims to add withKey methods to KGroupedTable interface.
This PR is part of KIP-149.
I separated the complete PR into 4 parts as discussed in here. So, this PR concentrates on adding withKey methods to KGroupedTable interface.