You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/07 06:45:19 UTC

[GitHub] [shardingsphere] soulasuna commented on a diff in pull request #17408: Optimize simple hint shadow algorithm

soulasuna commented on code in PR #17408:
URL: https://github.com/apache/shardingsphere/pull/17408#discussion_r867313579


##########
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java:
##########
@@ -53,8 +65,17 @@ public boolean isShadow(final Collection<String> shadowTableNames, final Precise
         if (ShadowOperationType.HINT_MATCH != noteShadowValue.getShadowOperationType() && !shadowTableNames.contains(noteShadowValue.getLogicTableName())) {
             return false;
         }
-        return ShadowHintExtractor.extractSimpleHint(noteShadowValue.getValue())
-                .filter(optional -> props.entrySet().stream().allMatch(entry -> Objects.equals(entry.getValue(), optional.get(String.valueOf(entry.getKey()))))).isPresent();
+        return ShadowHintExtractor.extractSimpleHint(noteShadowValue.getValue()).filter(this::containsHint).isPresent();
+    }
+    
+    private boolean containsHint(final Map<String, String> preciseHint) {
+        for (Map.Entry<String, String> entry : simpleHint.entrySet()) {

Review Comment:
   I will fix it.



##########
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithm.java:
##########
@@ -53,8 +65,17 @@ public boolean isShadow(final Collection<String> shadowTableNames, final Precise
         if (ShadowOperationType.HINT_MATCH != noteShadowValue.getShadowOperationType() && !shadowTableNames.contains(noteShadowValue.getLogicTableName())) {
             return false;
         }
-        return ShadowHintExtractor.extractSimpleHint(noteShadowValue.getValue())
-                .filter(optional -> props.entrySet().stream().allMatch(entry -> Objects.equals(entry.getValue(), optional.get(String.valueOf(entry.getKey()))))).isPresent();
+        return ShadowHintExtractor.extractSimpleHint(noteShadowValue.getValue()).filter(this::containsHint).isPresent();
+    }
+    
+    private boolean containsHint(final Map<String, String> preciseHint) {
+        for (Map.Entry<String, String> entry : simpleHint.entrySet()) {
+            if (entry.getValue().equals(preciseHint.get(entry.getKey()))) {
+                continue;

Review Comment:
   I will fix it.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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