提交 06a3f5d5 编写于 作者: T terrymanu

For #673: HashMap = LinkedHashMap for test case

上级 382264fd
...@@ -233,26 +233,26 @@ public final class SQLRewriteEngine { ...@@ -233,26 +233,26 @@ public final class SQLRewriteEngine {
private Map<String, String> getTableTokens(final TableUnit tableUnit) { private Map<String, String> getTableTokens(final TableUnit tableUnit) {
String logicTableName = tableUnit.getLogicTableName().toLowerCase(); String logicTableName = tableUnit.getLogicTableName().toLowerCase();
Map<String, String> tableTokens = new HashMap<>(); Map<String, String> result = new HashMap<>();
tableTokens.put(logicTableName, tableUnit.getActualTableName()); result.put(logicTableName, tableUnit.getActualTableName());
Optional<BindingTableRule> bindingTableRule = shardingRule.findBindingTableRule(logicTableName); Optional<BindingTableRule> bindingTableRule = shardingRule.findBindingTableRule(logicTableName);
if (bindingTableRule.isPresent()) { if (bindingTableRule.isPresent()) {
tableTokens.putAll(getBindingTableTokens(tableUnit, bindingTableRule.get())); result.putAll(getBindingTableTokens(tableUnit, bindingTableRule.get()));
} }
return tableTokens; return result;
} }
private Map<String, String> getTableTokens(final CartesianTableReference cartesianTableReference) { private Map<String, String> getTableTokens(final CartesianTableReference cartesianTableReference) {
Map<String, String> tableTokens = new HashMap<>(); Map<String, String> result = new HashMap<>();
for (TableUnit each : cartesianTableReference.getTableUnits()) { for (TableUnit each : cartesianTableReference.getTableUnits()) {
String logicTableName = each.getLogicTableName().toLowerCase(); String logicTableName = each.getLogicTableName().toLowerCase();
tableTokens.put(logicTableName, each.getActualTableName()); result.put(logicTableName, each.getActualTableName());
Optional<BindingTableRule> bindingTableRule = shardingRule.findBindingTableRule(logicTableName); Optional<BindingTableRule> bindingTableRule = shardingRule.findBindingTableRule(logicTableName);
if (bindingTableRule.isPresent()) { if (bindingTableRule.isPresent()) {
tableTokens.putAll(getBindingTableTokens(each, bindingTableRule.get())); result.putAll(getBindingTableTokens(each, bindingTableRule.get()));
} }
} }
return tableTokens; return result;
} }
private Map<String, String> getBindingTableTokens(final TableUnit tableUnit, final BindingTableRule bindingTableRule) { private Map<String, String> getBindingTableTokens(final TableUnit tableUnit, final BindingTableRule bindingTableRule) {
......
...@@ -25,13 +25,12 @@ import lombok.Setter; ...@@ -25,13 +25,12 @@ import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Sharding rule configuration for yaml. * Sharding rule configuration for yaml.
...@@ -44,7 +43,7 @@ public class YamlShardingRuleConfiguration { ...@@ -44,7 +43,7 @@ public class YamlShardingRuleConfiguration {
private String defaultDataSourceName; private String defaultDataSourceName;
private Map<String, YamlTableRuleConfiguration> tables = new HashMap<>(); private Map<String, YamlTableRuleConfiguration> tables = new LinkedHashMap<>();
private List<String> bindingTables = new ArrayList<>(); private List<String> bindingTables = new ArrayList<>();
...@@ -54,9 +53,9 @@ public class YamlShardingRuleConfiguration { ...@@ -54,9 +53,9 @@ public class YamlShardingRuleConfiguration {
private String defaultKeyGeneratorClass; private String defaultKeyGeneratorClass;
private Map<String, YamlMasterSlaveRuleConfiguration> masterSlaveRules = new HashMap<>(); private Map<String, YamlMasterSlaveRuleConfiguration> masterSlaveRules = new LinkedHashMap<>();
private Map<String, Object> configMap = new ConcurrentHashMap<>(); private Map<String, Object> configMap = new LinkedHashMap<>();
private Properties props = new Properties(); private Properties props = new Properties();
......
...@@ -34,7 +34,7 @@ import org.springframework.core.env.Environment; ...@@ -34,7 +34,7 @@ import org.springframework.core.env.Environment;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -52,7 +52,7 @@ public class SpringBootConfiguration implements EnvironmentAware { ...@@ -52,7 +52,7 @@ public class SpringBootConfiguration implements EnvironmentAware {
@Autowired @Autowired
private SpringBootMasterSlaveRuleConfigurationProperties masterSlaveProperties; private SpringBootMasterSlaveRuleConfigurationProperties masterSlaveProperties;
private final Map<String, DataSource> dataSourceMap = new HashMap<>(); private final Map<String, DataSource> dataSourceMap = new LinkedHashMap<>();
/** /**
* Get data source bean. * Get data source bean.
......
...@@ -20,7 +20,7 @@ package io.shardingjdbc.core.executor.threadlocal; ...@@ -20,7 +20,7 @@ package io.shardingjdbc.core.executor.threadlocal;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -35,7 +35,7 @@ public final class ExecutorDataMap { ...@@ -35,7 +35,7 @@ public final class ExecutorDataMap {
@Override @Override
protected Map<String, Object> initialValue() { protected Map<String, Object> initialValue() {
return new HashMap<>(); return new LinkedHashMap<>();
} }
}; };
......
...@@ -24,7 +24,7 @@ import lombok.Getter; ...@@ -24,7 +24,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -40,7 +40,7 @@ public final class BatchPreparedStatementUnit implements BaseStatementUnit { ...@@ -40,7 +40,7 @@ public final class BatchPreparedStatementUnit implements BaseStatementUnit {
private final PreparedStatement statement; private final PreparedStatement statement;
private final Map<Integer, Integer> jdbcAndActualAddBatchCallTimesMap = new HashMap<>(); private final Map<Integer, Integer> jdbcAndActualAddBatchCallTimesMap = new LinkedHashMap<>();
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
private int actualCallAddBatchTimes; private int actualCallAddBatchTimes;
......
...@@ -36,7 +36,7 @@ import org.springframework.util.StringUtils; ...@@ -36,7 +36,7 @@ import org.springframework.util.StringUtils;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -48,7 +48,7 @@ import java.util.Map; ...@@ -48,7 +48,7 @@ import java.util.Map;
@EnableConfigurationProperties({SpringBootShardingRuleConfigurationProperties.class, SpringBootMasterSlaveRuleConfigurationProperties.class, SpringBootOrchestrationConfigurationProperties.class}) @EnableConfigurationProperties({SpringBootShardingRuleConfigurationProperties.class, SpringBootMasterSlaveRuleConfigurationProperties.class, SpringBootOrchestrationConfigurationProperties.class})
public class OrchestrationSpringBootConfiguration implements EnvironmentAware { public class OrchestrationSpringBootConfiguration implements EnvironmentAware {
private final Map<String, DataSource> dataSourceMap = new HashMap<>(); private final Map<String, DataSource> dataSourceMap = new LinkedHashMap<>();
@Autowired @Autowired
private SpringBootShardingRuleConfigurationProperties shardingProperties; private SpringBootShardingRuleConfigurationProperties shardingProperties;
......
...@@ -36,7 +36,7 @@ import io.shardingjdbc.orchestration.reg.zookeeper.ZookeeperRegistryCenter; ...@@ -36,7 +36,7 @@ import io.shardingjdbc.orchestration.reg.zookeeper.ZookeeperRegistryCenter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
...@@ -128,7 +128,7 @@ public final class OrchestrationFacade implements AutoCloseable { ...@@ -128,7 +128,7 @@ public final class OrchestrationFacade implements AutoCloseable {
} }
private Map<String, DataSource> getActualDataSourceMapForMasterSlave(final Map<String, DataSource> dataSourceMap) { private Map<String, DataSource> getActualDataSourceMapForMasterSlave(final Map<String, DataSource> dataSourceMap) {
Map<String, DataSource> result = new HashMap<>(); Map<String, DataSource> result = new LinkedHashMap<>();
for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) { for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
if (entry.getValue() instanceof MasterSlaveDataSource) { if (entry.getValue() instanceof MasterSlaveDataSource) {
MasterSlaveDataSource masterSlaveDataSource = (MasterSlaveDataSource) entry.getValue(); MasterSlaveDataSource masterSlaveDataSource = (MasterSlaveDataSource) entry.getValue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册