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
Conversation
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.
Overall LGTM! Left some comments. Thanks.
storage/src/main/java/org/apache/kafka/storage/internals/log/LogStartOffsetIncrementReason.java
Outdated
Show resolved
Hide resolved
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java
Outdated
Show resolved
Hide resolved
@@ -202,7 +202,7 @@ final class KafkaMetadataLog private ( | |||
} | |||
|
|||
override def highWatermark: LogOffsetMetadata = { | |||
val LogOffsetSnapshot(_, _, hwm, _) = log.fetchOffsetSnapshot | |||
val hwm = log.fetchOffsetSnapshot.highWatermark |
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.
nice refactor!
shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch) | ||
shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch, Collections.emptyList[RecordError], null, | ||
LeaderHwChange.NONE) |
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.
Why do we need to explicitly set default value here?
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.
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.
Thanks @showuon for your review. Addressed them with inline replies or the latest commits. |
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.
@satishd : Thanks for the PR. A couple of comments below.
/** | ||
* Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}. | ||
*/ | ||
public class LogReadInfo { |
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.
All scala case classes define equal()
and hashcode()
. Do we need to define those explicitly in java?
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.
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.
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.
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.
Thanks @junrao for your review. Addressed them with the latest commit. |
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.
@satishd : Thanks for the updated PR. A couple of more comments.
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java
Show resolved
Hide resolved
storage/src/main/java/org/apache/kafka/storage/internals/log/LogOffsetSnapshot.java
Show resolved
Hide resolved
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java
Outdated
Show resolved
Hide resolved
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.
@satishd : Thanks for the updated. One more comment.
|
||
return firstEntryIncomplete != that.firstEntryIncomplete && | ||
Objects.equals(fetchOffsetMetadata, that.fetchOffsetMetadata) && | ||
Objects.equals(records, that.records) && |
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.
Hmm, FileRecords doesn't implement equals
. So, maybe LogReadInfo should never be used for comparison?
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.
+1, we can leave LogReadInfo not to implement equals/hashCode as it is not really needed with the current usages.
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.
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
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.
@satishd : Thanks for the updated PR. LGTM
KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module
Committer Checklist (excluded from commit message)