-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-3902 #1556
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-3902 #1556
Changes from 7 commits
3827d91
e07388b
3563044
721e00d
0a93d16
1919fa5
aa036cb
a607e24
e6beae8
a8f9ef7
7c277cf
73479d3
b039e4e
356b0a6
66aada0
b2f5c06
0fe41c8
5b19a71
c1e4ddf
117c661
525d1b4
1dccdba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ class KTableFilter<K, V> implements KTableProcessorSupplier<K, V, V> { | |
| private final Predicate<K, V> predicate; | ||
| private final boolean filterNot; | ||
|
|
||
| private boolean sendOldValues = false; | ||
| private boolean sendOldValues = true; | ||
|
|
||
| public KTableFilter(KTableImpl<K, ?, V> parent, Predicate<K, V> predicate, boolean filterNot) { | ||
| this.parent = parent; | ||
|
|
@@ -77,6 +77,7 @@ public void process(K key, Change<V> change) { | |
| V newValue = computeValue(key, change.newValue); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add a check on the original
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean something semantically equivalent to I'd like to understand whether you're addressing case 2 alone or case 2 and 3. Once I am clear on what you mean, I can make change and test.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually never mind, I was originally thinking that after this patch we should |
||
| V oldValue = sendOldValues ? computeValue(key, change.oldValue) : null; | ||
|
|
||
| if (sendOldValues && oldValue == null && newValue == null) return; // unnecessary to forward here. | ||
| context().forward(key, new Change<>(newValue, 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.
My concern is that, the overhead of requesting the source KTable to be materialized (i.e. creating a state store, and sending the {old -> new} pair instead of the new value only) may be over-whelming compared with its potential benefits of reducing the downstream traffic.
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.
I am looking for your guidance here. On the one hand, I think your point has merit and have difficulty assessing the tradeoff given limited knowledge of app usage and app internals; on the other hand, I'd be very curious to hear what comparable projects do in similar situation (I read Samza's demonstration of materialized tables and user clicks example, so perhaps you have familiarity with Samza's or others' design decisions if in sync with K-Streams, you might have worked on that project as well). Specifically, I wonder if the rationale you had presented for case 2 in the JIRA statement (sendOldValues=false) really requires sending keys with nulls on false evaluation of filter (is that how Samza would do it too?). If case 2's rationale can be challenged, then this ticket can have a meaningful outcome, otherwise it seems that this ticket can not lead to a behaviour change.
I'd be happy to reset this to false if you find that more advisable. But then, I don't see any hook at higher level of abstraction to enable sending old values so that for instance RegionView example from Confluent would work without a final filter to exclude nulls on Long deserializer.
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.
Samza does not have a high-level DSL interface, so it dos not have this issue.
This issue is related to the more general question that when should we materialize a KTable object with a state store, and currently the rule is that stateless operators like filters should not necessarily materialize it. That being said, if a further downstream operator is stateful, it will cause backward propagation of setting
enableSendOldValuesto true up till the source KTable, as I mentioned in the email thread.