Skip to content

Commit

Permalink
Refactor ShadowRule (#33946)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Dec 6, 2024
1 parent 8b47d30 commit 7eb662e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.shardingsphere.shadow.rule;

import com.cedarsoftware.util.CaseInsensitiveMap;
import lombok.Getter;
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
Expand Down Expand Up @@ -77,12 +78,13 @@ private Map<String, ShadowAlgorithm> createShadowAlgorithms(final Map<String, Al

private Map<String, ShadowDataSourceRule> createDataSourceRules(final Collection<ShadowDataSourceConfiguration> dataSourceConfigs) {
return dataSourceConfigs.stream().collect(Collectors.toMap(ShadowDataSourceConfiguration::getName,
each -> new ShadowDataSourceRule(each.getProductionDataSourceName(), each.getShadowDataSourceName()), (a, b) -> b, LinkedHashMap::new));
each -> new ShadowDataSourceRule(each.getProductionDataSourceName(), each.getShadowDataSourceName()), (a, b) -> b, CaseInsensitiveMap::new));
}

private Map<String, ShadowTableRule> createTableRules(final Map<String, ShadowTableConfiguration> tableConfigs) {
return tableConfigs.entrySet().stream().collect(Collectors.toMap(Entry::getKey,
entry -> new ShadowTableRule(entry.getKey(), entry.getValue().getDataSourceNames(), entry.getValue().getShadowAlgorithmNames(), shadowAlgorithms), (a, b) -> b, LinkedHashMap::new));
entry -> new ShadowTableRule(entry.getKey(), entry.getValue().getDataSourceNames(), entry.getValue().getShadowAlgorithmNames(), shadowAlgorithms),
(a, b) -> b, CaseInsensitiveMap::new));
}

/**
Expand Down

0 comments on commit 7eb662e

Please sign in to comment.