poorbarcode commented on code in PR #18877: URL: https://github.com/apache/pulsar/pull/18877#discussion_r1052795762
########## pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java: ########## @@ -2017,6 +2027,25 @@ private void handleLastMessageIdFromCompactedLedger(PersistentTopic persistentTo }); } + private int calculateTheLastBatchIndexInBatch(MessageMetadata metadata, ByteBuf payload) throws IOException { + int batchSize = metadata.getNumMessagesInBatch(); + if (batchSize <= 1){ + return -1; + } + SingleMessageMetadata singleMessageMetadata = new SingleMessageMetadata(); + int lastBatchIndexInBatch = -1; + for (int i = 0; i < batchSize; i++){ + ByteBuf singleMessagePayload = + Commands.deSerializeSingleMessageInBatch(payload, singleMessageMetadata, i, batchSize); + singleMessagePayload.release(); + if (singleMessageMetadata.isCompactedOut()){ + continue; Review Comment: Hi Bo The constructor of batched message entry is `[single_msg_size_1, single_msg_content_1, single_msg_size_2, single_msg_content_2......]`, we can not extract the last internal message directly. same as https://github.com/apache/pulsar/pull/18877/files/b428afd7916b94542a20acf8f1f029bddcc0da81#r1050335022 -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org