szetszwo commented on code in PR #1249:
URL: https://github.com/apache/ratis/pull/1249#discussion_r2051562497


##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java:
##########
@@ -117,6 +117,10 @@ int size() {
       return map.size();
     }
 
+    boolean contains(long index) {
+      return map.containsKey(index);
+    }

Review Comment:
   contain(..) is not needed.



##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/LogSegment.java:
##########
@@ -514,7 +519,7 @@ synchronized ReferenceCountedObject<LogEntryProto> 
loadCache(TermIndex ti) throw
   }
 
   LogRecord getLogRecord(long index) {
-    if (index >= startIndex && index <= endIndex) {
+    if (records.contains(index)) {
       return records.get(index);
     }

Review Comment:
   Just return without calling `contain(..)`:
   ```jav
     LogRecord getLogRecord(long index) {
       return records.get(index);
     }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to