You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "satishd (via GitHub)" <gi...@apache.org> on 2023/02/25 03:29:12 UTC

[GitHub] [kafka] satishd opened a new pull request, #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

satishd opened a new pull request, #13304:
URL: https://github.com/apache/kafka/pull/13304

   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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd merged pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd merged PR #13304:
URL: https://github.com/apache/kafka/pull/13304


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] showuon commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1118032062


##########
core/src/main/scala/kafka/raft/KafkaMetadataLog.scala:
##########
@@ -202,7 +202,7 @@ final class KafkaMetadataLog private (
   }
 
   override def highWatermark: LogOffsetMetadata = {
-    val LogOffsetSnapshot(_, _, hwm, _) = log.fetchOffsetSnapshot
+    val hwm = log.fetchOffsetSnapshot.highWatermark

Review Comment:
   nice refactor!



##########
core/src/main/scala/kafka/log/UnifiedLog.scala:
##########
@@ -1112,7 +1079,8 @@ class UnifiedLog(@volatile var logStartOffset: Long,
 
     new LogAppendInfo(firstOffset, lastOffset, lastLeaderEpochOpt, maxTimestamp, offsetOfMaxTimestamp,
       RecordBatch.NO_TIMESTAMP, logStartOffset, RecordConversionStats.EMPTY, sourceCompression, targetCompression,
-      shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch)
+      shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch, Collections.emptyList[RecordError], null,
+      LeaderHwChange.NONE)

Review Comment:
   Why do we need to explicitly set default value here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #13304:
URL: https://github.com/apache/kafka/pull/13304#issuecomment-1445917205

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #13304:
URL: https://github.com/apache/kafka/pull/13304#issuecomment-1450425363

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] junrao commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "junrao (via GitHub)" <gi...@apache.org>.
junrao commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1119112476


##########
core/src/main/scala/kafka/cluster/Partition.scala:
##########
@@ -1434,13 +1434,13 @@ class Partition(val topicPartition: TopicPartition,
       minOneMessage
     )
 
-    LogReadInfo(
-      fetchedData = fetchedData,
-      divergingEpoch = None,
-      highWatermark = initialHighWatermark,
-      logStartOffset = initialLogStartOffset,
-      logEndOffset = initialLogEndOffset,
-      lastStableOffset = initialLastStableOffset
+    new LogReadInfo(
+      fetchedData,
+      Optional.empty[FetchResponseData.EpochEndOffset](),

Review Comment:
   Could we just do `Optional.empty()`?



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1118411232


##########
core/src/main/scala/kafka/log/UnifiedLog.scala:
##########
@@ -1112,7 +1079,8 @@ class UnifiedLog(@volatile var logStartOffset: Long,
 
     new LogAppendInfo(firstOffset, lastOffset, lastLeaderEpochOpt, maxTimestamp, offsetOfMaxTimestamp,
       RecordBatch.NO_TIMESTAMP, logStartOffset, RecordConversionStats.EMPTY, sourceCompression, targetCompression,
-      shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch)
+      shallowMessageCount, validBytesCount, monotonic, lastOffsetOfFirstBatch, Collections.emptyList[RecordError], null,
+      LeaderHwChange.NONE)

Review Comment:
   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. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] junrao commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "junrao (via GitHub)" <gi...@apache.org>.
junrao commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1120915339


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {
+
+    public final FetchDataInfo fetchedData;
+    public final Optional<FetchResponseData.EpochEndOffset> divergingEpoch;
+    public final long highWatermark;
+    public final long logStartOffset;
+    public final long logEndOffset;
+    public final long lastStableOffset;
+
+    public LogReadInfo(FetchDataInfo fetchedData,

Review Comment:
   Should we define `equals()` and `hashCode()` for FetchDataInfo too?



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogOffsetSnapshot.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+/**
+ * Container class which represents a snapshot of the significant offsets for a partition. This allows fetching
+ * of these offsets atomically without the possibility of a leader change affecting their consistency relative
+ * to each other. See {@link UnifiedLog#fetchOffsetSnapshot()}.
+ */
+public class LogOffsetSnapshot {

Review Comment:
   Should we define equals() and hashCode()?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1121995162


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {

Review Comment:
   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. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] ijuma commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1120933335


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {

Review Comment:
   Note that `case` 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.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] ijuma commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1120933708


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {
+
+    public final FetchDataInfo fetchedData;
+    public final Optional<FetchResponseData.EpochEndOffset> divergingEpoch;
+    public final long highWatermark;
+    public final long logStartOffset;
+    public final long logEndOffset;
+    public final long lastStableOffset;
+
+    public LogReadInfo(FetchDataInfo fetchedData,
+                       Optional<FetchResponseData.EpochEndOffset> divergingEpoch,
+                       long highWatermark,
+                       long logStartOffset,
+                       long logEndOffset,
+                       long lastStableOffset) {
+        this.fetchedData = fetchedData;
+        this.divergingEpoch = divergingEpoch;
+        this.highWatermark = highWatermark;
+        this.logStartOffset = logStartOffset;
+        this.logEndOffset = logEndOffset;
+        this.lastStableOffset = lastStableOffset;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        LogReadInfo that = (LogReadInfo) o;
+
+        return highWatermark == that.highWatermark &&
+                logStartOffset == that.logStartOffset &&
+                logEndOffset == that.logEndOffset &&
+                lastStableOffset == that.lastStableOffset &&
+                Objects.equals(fetchedData, that.fetchedData) &&
+                Objects.equals(divergingEpoch, that.divergingEpoch);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = fetchedData != null ? fetchedData.hashCode() : 0;
+        result = 31 * result + (divergingEpoch != null ? divergingEpoch.hashCode() : 0);
+        result = 31 * result + (int) (highWatermark ^ (highWatermark >>> 32));
+        result = 31 * result + (int) (logStartOffset ^ (logStartOffset >>> 32));
+        result = 31 * result + (int) (logEndOffset ^ (logEndOffset >>> 32));
+        result = 31 * result + (int) (lastStableOffset ^ (lastStableOffset >>> 32));

Review Comment:
   We should use `Long.hashCode` in many of these lines.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1121995162


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using {@link kafka.cluster.Partition#fetchRecords()}.
+ */
+public class LogReadInfo {

Review Comment:
   This is the reason I did not add it earlier. But I am not strongly opinionated about that. 
   I added them with the latest commit. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] showuon commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1118031367


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogReadInfo.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.storage.internals.log;
+
+import org.apache.kafka.common.message.FetchResponseData;
+
+import java.util.Optional;
+
+/**
+ * Structure used for lower level reads using  [[kafka.cluster.Partition.fetchRecords()]].

Review Comment:
   The java doc needs to be updated to java style with `@link` 



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogStartOffsetIncrementReason.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.storage.internals.log;
+
+public enum LogStartOffsetIncrementReason {
+    LeaderOffsetIncremented("leader offset increment"),
+    SegmentDeletion("segment deletion"),
+    ClientRecordDeletion("client delete records request"),
+    SnapshotGenerated("snapshot generated");
+
+    private final String value;

Review Comment:
   nit: rename the `value` to a meaningful name, ex: `reason`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] ijuma commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1124016717


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/FetchDataInfo.java:
##########
@@ -44,6 +45,28 @@ public FetchDataInfo(LogOffsetMetadata fetchOffsetMetadata,
         this.abortedTransactions = abortedTransactions;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        FetchDataInfo that = (FetchDataInfo) o;
+
+        return firstEntryIncomplete != that.firstEntryIncomplete &&
+                Objects.equals(fetchOffsetMetadata, that.fetchOffsetMetadata) &&
+                Objects.equals(records, that.records) &&

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] junrao commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "junrao (via GitHub)" <gi...@apache.org>.
junrao commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1123584048


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/FetchDataInfo.java:
##########
@@ -44,6 +45,28 @@ public FetchDataInfo(LogOffsetMetadata fetchOffsetMetadata,
         this.abortedTransactions = abortedTransactions;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        FetchDataInfo that = (FetchDataInfo) o;
+
+        return firstEntryIncomplete != that.firstEntryIncomplete &&
+                Objects.equals(fetchOffsetMetadata, that.fetchOffsetMetadata) &&
+                Objects.equals(records, that.records) &&

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on a diff in pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #13304:
URL: https://github.com/apache/kafka/pull/13304#discussion_r1124009466


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/FetchDataInfo.java:
##########
@@ -44,6 +45,28 @@ public FetchDataInfo(LogOffsetMetadata fetchOffsetMetadata,
         this.abortedTransactions = abortedTransactions;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        FetchDataInfo that = (FetchDataInfo) o;
+
+        return firstEntryIncomplete != that.firstEntryIncomplete &&
+                Objects.equals(fetchOffsetMetadata, that.fetchOffsetMetadata) &&
+                Objects.equals(records, that.records) &&

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] satishd commented on pull request #13304: KAFKA-14726 Move/rewrite of LogReadInfo, LogOffsetSnapshot, LogStartOffsetIncrementReason to storage module

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #13304:
URL: https://github.com/apache/kafka/pull/13304#issuecomment-1448587425

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org