You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/12/17 07:06:58 UTC

[GitHub] [rocketmq] duhenglucky commented on a change in pull request #3616: [ISSUE 3613] bug fix, solve message hash conflict in index file

duhenglucky commented on a change in pull request #3616:
URL: https://github.com/apache/rocketmq/pull/3616#discussion_r771149857



##########
File path: store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
##########
@@ -21,13 +21,30 @@
 package org.apache.rocketmq.store.index;
 
 import java.io.File;
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.Pair;
 import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.store.*;

Review comment:
       Please don't aggregate all imports with *

##########
File path: store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
##########
@@ -993,6 +985,29 @@ public QueryMessageResult queryMessage(String topic, String key, int maxNum, lon
         return queryMessageResult;
     }
 
+    /**
+     * check target msg match
+     *
+     * @param msg   message
+     * @param topic topic
+     * @param key   message key
+     * @return  is match
+     */
+    private boolean isMessageMatch(MessageExt msg, String topic, String key) {
+        String keys = msg.getKeys();
+        if (Objects.equals(topic, msg.getTopic()) && StringUtils.isNotEmpty(keys)) {
+            String[] keyArray = keys.split(MessageConst.KEY_SEPARATOR);
+            if (keyArray.length > 0) {
+                for (String k : keyArray) {

Review comment:
       Same as last comment

##########
File path: store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
##########
@@ -948,24 +952,12 @@ public QueryMessageResult queryMessage(String topic, String key, int maxNum, lon
                 long offset = queryOffsetResult.getPhyOffsets().get(m);
 
                 try {
-
-                    boolean match = true;

Review comment:
       Actually match isn't used in broker, so how about move the check logic to client?




-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org