This is an automated email from the ASF dual-hosted git repository. jinrongtong pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push: new 263f0fbdd6 [ISSUE #8448] commitlog class comment optimize 263f0fbdd6 is described below commit 263f0fbdd6e972ec2de117a476ac404aa9d6c591 Author: Qiu <472594...@qq.com> AuthorDate: Mon Jul 29 13:46:46 2024 +0800 [ISSUE #8448] commitlog class comment optimize --- .../main/java/org/apache/rocketmq/store/CommitLog.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java index 1dd60523a5..f707d8fbd8 100644 --- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java +++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java @@ -1964,23 +1964,28 @@ public class CommitLog implements Swappable { queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills); } - int pos = 4 + 4 + 4 + 4 + 4; + int pos = 4 // 1 TOTALSIZE + + 4 // 2 MAGICCODE + + 4 // 3 BODYCRC + + 4 // 4 QUEUEID + + 4; // 5 FLAG // 6 QUEUEOFFSET preEncodeBuffer.putLong(pos, queueOffset); pos += 8; // 7 PHYSICALOFFSET preEncodeBuffer.putLong(pos, fileFromOffset + byteBuffer.position()); + pos += 8; int ipLen = (msgInner.getSysFlag() & MessageSysFlag.BORNHOST_V6_FLAG) == 0 ? 4 + 4 : 16 + 4; - // 8 SYSFLAG, 9 BORNTIMESTAMP, 10 BORNHOST, 11 STORETIMESTAMP - pos += 8 + 4 + 8 + ipLen; - // refresh store time stamp in lock + // 8 SYSFLAG, 9 BORNTIMESTAMP, 10 BORNHOST + pos += 4 + 8 + ipLen; + // 11 STORETIMESTAMP refresh store time stamp in lock preEncodeBuffer.putLong(pos, msgInner.getStoreTimestamp()); if (enabledAppendPropCRC) { // 18 CRC32 int checkSize = msgLen - crc32ReservedLength; ByteBuffer tmpBuffer = preEncodeBuffer.duplicate(); tmpBuffer.limit(tmpBuffer.position() + checkSize); - int crc32 = UtilAll.crc32(tmpBuffer); + int crc32 = UtilAll.crc32(tmpBuffer); // UtilAll.crc32 function will change the position to limit of the buffer tmpBuffer.limit(tmpBuffer.position() + crc32ReservedLength); MessageDecoder.createCrc32(tmpBuffer, crc32); }