cdmaji commented on code in PR #5456:
URL: https://github.com/apache/rocketmq/pull/5456#discussion_r1014959009


##########
store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java:
##########
@@ -1001,4 +1002,20 @@ public void swapMap(int reserveNum, long 
forceSwapIntervalMs, long normalSwapInt
     public void cleanSwappedMap(long forceCleanSwapIntervalMs) {
         mappedFileQueue.cleanSwappedMap(forceCleanSwapIntervalMs);
     }
+
+    private int getEarliestOffset(int targetOffset, ByteBuffer byteBuffer, 
long currentStoreTime) {
+        if (targetOffset == 0) {
+            return targetOffset;
+        }
+        int preOffset = targetOffset - CQ_STORE_UNIT_SIZE;
+        byteBuffer.position(preOffset);
+        long prePhyOffset = byteBuffer.getLong();
+        int preSize = byteBuffer.getInt();
+        long preStoreTime =
+                
this.messageStore.getCommitLog().pickupStoreTimestamp(prePhyOffset, preSize);
+        if (currentStoreTime == preStoreTime) {
+            targetOffset = getEarliestOffset(preOffset, byteBuffer, 
preStoreTime);
+        }

Review Comment:
   Okay, I'll optimize it later



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