pkumar-singh commented on a change in pull request #1949:
URL: https://github.com/apache/bookkeeper/pull/1949#discussion_r767915087



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogMetadata.java
##########
@@ -96,4 +109,111 @@ public String toString() {
         return sb.toString();
     }
 
+    /**
+     * Serializes {@link EntryLogMetadata} and writes to
+     * {@link DataOutputStream}.
+     * <pre>
+     * schema:
+     * 2-bytes: schema-version
+     * 8-bytes: entrylog-entryLogId
+     * 8-bytes: entrylog-totalSize
+     * 8-bytes: entrylog-remainingSize
+     * 8-bytes: total number of ledgers
+     * ledgers-map
+     * [repeat]: (8-bytes::ledgerId, 8-bytes::size-of-ledger)
+     * </pre>
+     * @param out
+     * @throws IOException
+     *             throws if it couldn't serialize metadata-fields
+     * @throws IllegalStateException
+     *             throws if it couldn't serialize ledger-map
+     */
+    public void serialize(DataOutputStream out) throws IOException, 
IllegalStateException {
+        out.writeShort(DEFAULT_SERIALIZATION_VERSION);
+        out.writeLong(entryLogId);
+        out.writeLong(totalSize);
+        out.writeLong(remainingSize);
+        out.writeLong(ledgersMap.size());
+        ledgersMap.forEach((ledgerId, size) -> {
+            try {

Review comment:
       Probably this is one of the reason to avoid lamba here. Just a normal 
iteration should be just fine.




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