add getPartitionIndex() to the Record<> - #9947
Merged
Merged
Conversation
1 task
jerrypeng
approved these changes
Mar 17, 2021
sijie
requested changes
Mar 18, 2021
| * | ||
| * @return The partition number | ||
| */ | ||
| default Optional<Integer> getPartitionNumber() { |
Member
There was a problem hiding this comment.
Suggested change
| default Optional<Integer> getPartitionNumber() { | |
| default Optional<Integer> getPartitionId() { |
Member
There was a problem hiding this comment.
I think parittion id it better than partition number
Contributor
Author
There was a problem hiding this comment.
@sijie I agree but default Optional<String> getPartitionId() { already defined on line 76.
eolivelli
requested changes
Mar 18, 2021
eolivelli
left a comment
Contributor
There was a problem hiding this comment.
overall looks good to me
but I left some comments
|
|
||
| AbstractKafkaSourceRecord(SourceRecord srcRecord) { | ||
| this.destinationTopic = Optional.of("persistent://"+topicNamespace + "/" + srcRecord.topic()); | ||
| this.partitionNumber = Optional.of(srcRecord.kafkaPartition()); |
|
|
||
| @Override | ||
| public Optional<Integer> getPartitionNumber() { | ||
| return Optional.of(record.partition()); |
Contributor
Author
There was a problem hiding this comment.
record.partition() returns int, cannot be null
|
|
||
| @Override | ||
| public Optional<Integer> getPartitionNumber() { | ||
| return Optional.of(partition); |
Contributor
Author
There was a problem hiding this comment.
int partition, cannot be null
eolivelli
approved these changes
Mar 22, 2021
codelipenghui
requested changes
Mar 24, 2021
codelipenghui
left a comment
Contributor
There was a problem hiding this comment.
Could you please add some tests for the new method introduced in the PR?
dlg99
force-pushed
the
record-partition-number
branch
from
March 24, 2021 17:51
0067e4f to
5206f01
Compare
codelipenghui
approved these changes
Mar 25, 2021
sijie
approved these changes
Mar 26, 2021
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Looking at #9927 (comment) there is no way to reliably get partition number.
There is Optional getPartitionId() which returns:
Modifications
Added
default Optional<Integer> getPartitionIndex()to theRecordinterface.Return partition number where appropriate.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesinterface Record<T>Documentation