sijie commented on a change in pull request #727: Issue 693: add interface and 
implementation of LedgerEntries
URL: https://github.com/apache/bookkeeper/pull/727#discussion_r151218118
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/LedgerEntries.java
 ##########
 @@ -0,0 +1,44 @@
+/**
+ * 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.bookkeeper.client.api;
+
+import java.util.Iterator;
+
+/**
+ * Interface to wrap the entries.
+ *
+ * @since 4.6
+ */
+public interface LedgerEntries {
+
+    /**
+     * Gets a specific LedgerEntry by entryId.
+     *
+     * @param entryId the LedgerEntry id
+     * @return the LedgerEntry
+     */
+    LedgerEntry getEntry(long entryId);
+
+    /**
+     * In this, It retains the references for the entries in this 
LedgerEntries.
+     * The caller who calls #iterator() is responsible for releasing the 
retained references.
 
 Review comment:
   @eolivelli - my take here is: when iterator is called, you are handing out 
the entries, you don't know when the caller will complete iterating the 
entries. in this case, you have to increment the refCnt. The application who is 
holding iterator should be responsible for releasing one refcnt that it retains 
for entries. 
   
   I think getting a more consistent behavior, we can follow the pattern that 
ByteBuf has, to have two methods: one is `iterator()`, the other one is 
`retainIterator()`. in `iterator` we don't need to increment the reference 
counts, while `retainIterator()`, it increment the reference counts. so user 
have a deterministic behavior - depends on how do they want to keep the 
iterators.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to