From d447eb586342329ae12e858179ce8486812f656d Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 4 Nov 2024 00:43:41 +0800 Subject: [PATCH] Refactor ShadowDataSourceMappingsFinderFactory --- .../engine/determiner/HintShadowAlgorithmDeterminer.java | 4 ++-- .../other/ShadowNonDMLStatementDataSourceMappingsFinder.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminer.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminer.java index 107020c2caf9f..2a535d3efd201 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminer.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminer.java @@ -41,11 +41,11 @@ public final class HintShadowAlgorithmDeterminer { * @return is shadow or not */ public static boolean isShadow(final HintShadowAlgorithm> shadowAlgorithm, final ShadowDetermineCondition shadowCondition, final ShadowRule shadowRule, final boolean useShadow) { - PreciseHintShadowValue> shadowValue = createNoteShadowValues(shadowCondition, useShadow); + PreciseHintShadowValue> shadowValue = createHintShadowValues(shadowCondition, useShadow); return shadowAlgorithm.isShadow(shadowRule.getAllShadowTableNames(), shadowValue); } - private static PreciseHintShadowValue> createNoteShadowValues(final ShadowDetermineCondition shadowDetermineCondition, final boolean useShadow) { + private static PreciseHintShadowValue> createHintShadowValues(final ShadowDetermineCondition shadowDetermineCondition, final boolean useShadow) { ShadowOperationType shadowOperationType = shadowDetermineCondition.getShadowOperationType(); String tableName = shadowDetermineCondition.getTableName(); return new PreciseHintShadowValue<>(tableName, shadowOperationType, useShadow); diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java index 68ce6113566c9..68c29ca3cfa6f 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/engine/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java @@ -41,13 +41,13 @@ public Map find(final ShadowRule rule) { if (!hintValueContext.isShadow()) { return Collections.emptyMap(); } - if (isMatchAnyNoteShadowAlgorithms(rule, new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH))) { + if (isMatchAnyHintShadowAlgorithms(rule, new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH))) { return rule.getAllShadowDataSourceMappings(); } return Collections.emptyMap(); } - private boolean isMatchAnyNoteShadowAlgorithms(final ShadowRule rule, final ShadowDetermineCondition shadowCondition) { + private boolean isMatchAnyHintShadowAlgorithms(final ShadowRule rule, final ShadowDetermineCondition shadowCondition) { return rule.getAllHintShadowAlgorithms().stream().anyMatch(each -> HintShadowAlgorithmDeterminer.isShadow(each, shadowCondition, rule, hintValueContext.isShadow())); } }