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-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module #13304

Merged
merged 7 commits into from Mar 4, 2023

Conversation

satishd
Copy link
Member

@satishd satishd commented Feb 25, 2023

KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Committer Checklist (excluded from commit message)

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

@satishd satishd marked this pull request as ready for review February 25, 2023 12:04
Copy link
Contributor

@showuon showuon left a comment

Choose a reason for hiding this comment

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

Overall LGTM! Left some comments. Thanks.

@@ -202,7 +202,7 @@ final class KafkaMetadataLog private (
}

override def highWatermark: LogOffsetMetadata = {
val LogOffsetSnapshot(_, _, hwm, _) = log.fetchOffsetSnapshot
val hwm = log.fetchOffsetSnapshot.highWatermark
Copy link
Contributor

Choose a reason for hiding this comment

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

nice refactor!

Comment on lines -1115 to +1083
shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch)
shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch, Collections.emptyList[RecordError], null,
LeaderHwChange.NONE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to explicitly set default value here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Earlier, we had default values in Scala. These changes did not introduce constructor overloading for different combinations as the usages were low. It is simpler to have a constructor and set this value from a couple of places.

@satishd
Copy link
Member Author

satishd commented Feb 27, 2023

Thanks @showuon for your review. Addressed them with inline replies or the latest commits.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@satishd : Thanks for the PR. A couple of comments below.

core/src/main/scala/kafka/cluster/Partition.scala Outdated Show resolved Hide resolved
/**
* Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
*/
public class LogReadInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

All scala case classes define equal() and hashcode(). Do we need to define those explicitly in java?

Copy link
Contributor

@ijuma ijuma Feb 28, 2023

Choose a reason for hiding this comment

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

Note that case class is used for many reasons. Do we actually need equals/hashCode (eg are these classes used as map keys or compared against each other)? If not, then it's maintenance overhead without benefit.

Copy link
Member Author

@satishd satishd Mar 1, 2023

Choose a reason for hiding this comment

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

Right. This is the reason I did not add it earlier. But I am not strongly opinionated about that.
I am fine adding them with the latest commit.

@satishd
Copy link
Member Author

satishd commented Feb 28, 2023

Thanks @junrao for your review. Addressed them with the latest commit.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@satishd : Thanks for the updated PR. A couple of more comments.

@satishd
Copy link
Member Author

satishd commented Mar 1, 2023

Thanks @junrao @ijuma for your review. Addressed the review comments with the latest commit.

Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@satishd : Thanks for the updated. One more comment.


return firstEntryIncomplete != that.firstEntryIncomplete &&
Objects.equals(fetchOffsetMetadata, that.fetchOffsetMetadata) &&
Objects.equals(records, that.records) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, FileRecords doesn't implement equals. So, maybe LogReadInfo should never be used for comparison?

Copy link
Member Author

Choose a reason for hiding this comment

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

+1, we can leave LogReadInfo not to implement equals/hashCode as it is not really needed with the current usages.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of having these methods implemented though? For example, what does it mean to compare a list of aborted transactions? Unless there are clear semantics, we're better off relying on reference equality only.

 - Removed equals and hashCode methods from LogReadInfo and FetchDataInfo
@satishd satishd requested a review from junrao March 3, 2023 15:40
Copy link
Contributor

@junrao junrao left a comment

Choose a reason for hiding this comment

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

@satishd : Thanks for the updated PR. LGTM

@satishd satishd merged commit 97105a8 into apache:trunk Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants