Skip to content
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-18694: Migrate suitable classes to recorods in coordinator-common module #18782

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

Rancho-7
Copy link
Contributor

@Rancho-7 Rancho-7 commented Feb 3, 2025

jira: https://issues.apache.org/jira/browse/KAFKA-18694

As title.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@github-actions github-actions bot added triage PRs from the community small Small PRs labels Feb 3, 2025
Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. I have some minor comments.

Comment on lines 34 to 35
private record TaskResult<R>(R result, Throwable exception) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we merge them into one line?

Suggested change
private record TaskResult<R>(R result, Throwable exception) {
}
private record TaskResult<R>(R result, Throwable exception) { }

Comment on lines 52 to 53
record LoadSummary(long startTimeMs, long endTimeMs, long schedulerQueueTimeMs, long numRecords, long numBytes) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines 136 to 137
private record Timestamped<T>(long timestamp, T value) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@Rancho-7
Copy link
Contributor Author

Rancho-7 commented Feb 3, 2025

Thanks for the patch. I have some minor comments.

Thanks for the comments.Fixed.

Comment on lines -87 to -95
@Override
public String toString() {
return "LoadSummary(" +
"startTimeMs=" + startTimeMs +
", endTimeMs=" + endTimeMs +
", schedulerQueueTimeMs=" + schedulerQueueTimeMs +
", numRecords=" + numRecords +
", numBytes=" + numBytes + ")";
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Record the default toString method will show "Square brackets" instead "Parentheses", ie. LoadSummary(...) will change to LoadSummary[...], If won't broken any test, I think it will be OK.

Copy link
Contributor

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rancho-7, thanks for this patch, LGTM

Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot removed the triage PRs from the community label Feb 4, 2025
@clolov clolov merged commit 22d4248 into apache:trunk Feb 5, 2025
9 checks passed
@ijuma
Copy link
Member

ijuma commented Feb 5, 2025

How are you evaluating if these classes can be safely converted? There are clear differences in behavior in equals/hashCode after these changes.

@Rancho-7
Copy link
Contributor Author

Rancho-7 commented Feb 6, 2025

How are you evaluating if these classes can be safely converted? There are clear differences in behavior in equals/hashCode after these changes.

Hi @ijuma

Thanks for catching this issue.You make a good point about the different behaviors in equals/hashCode.

While the Java SE docs mention these differences:

  • A method public final boolean equals(Object) that returns true if and only if the argument is an instance of R, and the current instance is equal to the argument instance at every record component of R; otherwise false is returned.
  • A method public final int hashCode() that returns a hash code value derived from the hash code values at every record component of R.

in our implementation we're actually comparing the object fields directly rather than using equals() for object comparison.E.g:


if (!oldResolvedRegularExpression.topics.equals(newResolvedRegularExpression.topics)) {

And we don't invoke hashCode() directly either.

Based on this approach, I believe these conversions should maintain compatibility without issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants