From b14d6095c2da4845f51028d2d53109215a49e803 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Mon, 4 Nov 2024 23:27:32 +0800 Subject: [PATCH] Refactor ShadowRule (#33547) --- .../shadow/rule/ShadowRule.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java index c2bd609b2537f..d884826638a55 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java @@ -132,9 +132,9 @@ public Collection getAllShadowTableNames() { } /** - * Get related hint shadow algorithms. + * Get all hint shadow algorithms. * - * @return related hint shadow algorithms + * @return all hint shadow algorithms */ @HighFrequencyInvocation @SuppressWarnings("unchecked") @@ -158,8 +158,7 @@ public Collection>> getAllHintShadowAlgorithms @SuppressWarnings("unchecked") public Collection>> getHintShadowAlgorithms(final String tableName) { Collection>> result = new LinkedList<>(); - Collection hintShadowAlgorithmNames = tableRules.get(tableName).getHintShadowAlgorithmNames(); - for (String each : hintShadowAlgorithmNames) { + for (String each : tableRules.get(tableName).getHintShadowAlgorithmNames()) { result.add((HintShadowAlgorithm>) shadowAlgorithms.get(each)); } return result; @@ -168,16 +167,16 @@ public Collection>> getHintShadowAlgorithms(fi /** * Get column shadow algorithms. * - * @param shadowOperationType shadow operation type + * @param operationType shadow operation type * @param tableName table name * @param shadowColumnName shadow column name * @return column shadow algorithms */ @HighFrequencyInvocation @SuppressWarnings("unchecked") - public Collection>> getColumnShadowAlgorithms(final ShadowOperationType shadowOperationType, final String tableName, final String shadowColumnName) { + public Collection>> getColumnShadowAlgorithms(final ShadowOperationType operationType, final String tableName, final String shadowColumnName) { Collection>> result = new LinkedList<>(); - for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(shadowOperationType, Collections.emptyList())) { + for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(operationType, Collections.emptyList())) { if (shadowColumnName.equals(each.getShadowColumnName())) { result.add((ColumnShadowAlgorithm>) shadowAlgorithms.get(each.getShadowAlgorithmName())); } @@ -188,14 +187,14 @@ public Collection>> getColumnShadowAlgorithm /** * Get shadow column names. * - * @param shadowOperationType shadow operation type + * @param operationType shadow operation type * @param tableName table name * @return got shadow column names */ @HighFrequencyInvocation - public Collection getShadowColumnNames(final ShadowOperationType shadowOperationType, final String tableName) { + public Collection getShadowColumnNames(final ShadowOperationType operationType, final String tableName) { Collection result = new LinkedList<>(); - for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(shadowOperationType, Collections.emptyList())) { + for (ShadowAlgorithmNameRule each : tableRules.get(tableName).getColumnShadowAlgorithmNames().getOrDefault(operationType, Collections.emptyList())) { result.add(each.getShadowColumnName()); } return result;