duongkame commented on code in PR #1049:
URL: https://github.com/apache/ratis/pull/1049#discussion_r1530685522


##########
ratis-server-api/src/main/java/org/apache/ratis/server/raftlog/RaftLog.java:
##########
@@ -79,6 +80,10 @@ default ReferenceCountedObject<LogEntryProto> retainLog(long 
index) throws RaftL
   /**
    * @return null if the log entry is not found in this log;
    *         otherwise, return the {@link EntryWithData} corresponding to the 
given index.
+   *         The {@link EntryWithData} enclosed retained underlying resource. 
The client code need to ensure either
+   *         calling {@link ReferenceCountedObject#release()} on the result of
+   *         {@link EntryWithData#getEntryRef(TimeDuration)} or {@link 
EntryWithData#release()} if the entry
+   *         is discarded.

Review Comment:
   Without updates, it won't call `getEntryRef` either, but `getEntry` which 
copies the returned `LogEntryProto`.
   I think it's convenient that EntryWithData returns the 
ReferenceCountedObject itself via an interface because next step we will accept 
`StateMachine.read` return a ReferenceCountedObject. This means there will be 
logic to combine the refs of the LogEntry and the data somewhere, and it's 
convenient to put it inside a method of `EntryWithData`.



-- 
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