-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-7895: fix stream-time reckoning for Suppress (2.1) (#6286) #6325
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,23 +30,36 @@ public class SuppressedInternal<K> implements Suppressed<K> { | |
| private final BufferConfigInternal bufferConfig; | ||
| private final Duration timeToWaitForMoreEvents; | ||
| private final TimeDefinition<K> timeDefinition; | ||
| private final boolean suppressTombstones; | ||
| private final boolean safeToDropTombstones; | ||
|
|
||
| /** | ||
| * @param safeToDropTombstones Note: it's *only* safe to drop tombstones for windowed KTables in "final results" mode. | ||
| * In that case, we have a priori knowledge that we have never before emitted any | ||
| * results for a given key, and therefore the tombstone is unnecessary (albeit | ||
| * idempotent and correct). We decided that the unnecessary tombstones would not be | ||
| * desirable in the output stream, though, hence the ability to drop them. | ||
| * | ||
| * A alternative is to remember whether a result has previously been emitted | ||
| * for a key and drop tombstones in that case, but it would be a little complicated to | ||
| * figure out when to forget the fact that we have emitted some result (currently, the | ||
| * buffer immediately forgets all about a key when we emit, which helps to keep it | ||
| * compact). | ||
| */ | ||
|
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. Likewise, this is part of the Suppress code legibility change. |
||
| public SuppressedInternal(final String name, | ||
| final Duration suppressionTime, | ||
| final BufferConfig bufferConfig, | ||
| final TimeDefinition<K> timeDefinition, | ||
| final boolean suppressTombstones) { | ||
| final boolean safeToDropTombstones) { | ||
| this.name = name; | ||
| this.timeToWaitForMoreEvents = suppressionTime == null ? DEFAULT_SUPPRESSION_TIME : suppressionTime; | ||
| this.timeDefinition = timeDefinition == null ? TimeDefinitions.RecordTimeDefintion.instance() : timeDefinition; | ||
| this.bufferConfig = bufferConfig == null ? DEFAULT_BUFFER_CONFIG : (BufferConfigInternal) bufferConfig; | ||
| this.suppressTombstones = suppressTombstones; | ||
| this.safeToDropTombstones = safeToDropTombstones; | ||
| } | ||
|
|
||
| @Override | ||
| public Suppressed<K> withName(final String name) { | ||
| return new SuppressedInternal<>(name, timeToWaitForMoreEvents, bufferConfig, timeDefinition, suppressTombstones); | ||
| return new SuppressedInternal<>(name, timeToWaitForMoreEvents, bufferConfig, timeDefinition, safeToDropTombstones); | ||
| } | ||
|
|
||
| public String name() { | ||
|
|
@@ -65,16 +78,20 @@ Duration timeToWaitForMoreEvents() { | |
| return timeToWaitForMoreEvents == null ? Duration.ZERO : timeToWaitForMoreEvents; | ||
| } | ||
|
|
||
| boolean shouldSuppressTombstones() { | ||
| return suppressTombstones; | ||
| boolean safeToDropTombstones() { | ||
| return safeToDropTombstones; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(final Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| final SuppressedInternal<?> that = (SuppressedInternal<?>) o; | ||
| return suppressTombstones == that.suppressTombstones && | ||
| return safeToDropTombstones == that.safeToDropTombstones && | ||
| Objects.equals(name, that.name) && | ||
| Objects.equals(bufferConfig, that.bufferConfig) && | ||
| Objects.equals(timeToWaitForMoreEvents, that.timeToWaitForMoreEvents) && | ||
|
|
@@ -83,7 +100,7 @@ public boolean equals(final Object o) { | |
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(name, bufferConfig, timeToWaitForMoreEvents, timeDefinition, suppressTombstones); | ||
| return Objects.hash(name, bufferConfig, timeToWaitForMoreEvents, timeDefinition, safeToDropTombstones); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -92,7 +109,7 @@ public String toString() { | |
| ", bufferConfig=" + bufferConfig + | ||
| ", timeToWaitForMoreEvents=" + timeToWaitForMoreEvents + | ||
| ", timeDefinition=" + timeDefinition + | ||
| ", suppressTombstones=" + suppressTombstones + | ||
| ", safeToDropTombstones=" + safeToDropTombstones + | ||
| '}'; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
streams/src/main/java/org/apache/kafka/streams/processor/internals/TimestampSupplier.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was an unrelated change in trunk/2.2 to improve the code legibility.
I'm proposing to backport it to keep the Suppress code consistent and improve maintainability.