This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 288044d0b37 Move Map.Entry from codes into import list (#26628)
288044d0b37 is described below
commit 288044d0b378c10148375c8df2af921015ca8d27
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jun 27 20:21:23 2023 +0800
Move Map.Entry from codes into import list (#26628)
---
.../metrics/core/exporter/impl/jdbc/JDBCMetaDataInfoExporter.java | 3 ++-
.../plugin/metrics/core/exporter/impl/jdbc/JDBCStateExporter.java | 3 ++-
.../mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java | 3 ++-
.../swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java | 3 ++-
.../handler/checker/ReadwriteSplittingRuleStatementChecker.java | 4 ++--
.../shadow/distsql/handler/checker/ShadowRuleStatementChecker.java | 4 ++--
.../distsql/handler/update/DropShadowRuleStatementUpdater.java | 5 +++--
.../pipeline/common/job/progress/JobItemInventoryTasksProgress.java | 3 ++-
.../ral/common/checker/EncryptRuleConfigurationImportChecker.java | 4 ++--
.../ral/common/checker/MaskRuleConfigurationImportChecker.java | 4 ++--
.../ral/common/checker/ShadowRuleConfigurationImportChecker.java | 4 ++--
.../ral/common/checker/ShardingRuleConfigurationImportChecker.java | 4 ++--
12 files changed, 25 insertions(+), 19 deletions(-)
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCMetaDataInfoExporter.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCMetaDataInfoExporter.java
index 6edf6e7d049..9afaf2e9bdf 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCMetaDataInfoExporter.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCMetaDataInfoExporter.java
@@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
/**
@@ -56,7 +57,7 @@ public final class JDBCMetaDataInfoExporter implements
MetricsExporter {
result.cleanMetrics();
DriverDataSourceCache dataSourceCache =
AgentReflectionUtils.getFieldValue(shardingSphereDriverOptional.get(),
"dataSourceCache");
Map<String, DataSource> dataSourceMap =
AgentReflectionUtils.getFieldValue(dataSourceCache, "dataSourceMap");
- for (Map.Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
+ for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
ShardingSphereDataSource shardingSphereDataSource =
(ShardingSphereDataSource) entry.getValue();
String databaseName =
AgentReflectionUtils.getFieldValue(shardingSphereDataSource, "databaseName");
ContextManager contextManager =
AgentReflectionUtils.getFieldValue(shardingSphereDataSource, "contextManager");
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCStateExporter.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCStateExporter.java
index eeae3651ea1..522ecd63db5 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCStateExporter.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/exporter/impl/jdbc/JDBCStateExporter.java
@@ -34,6 +34,7 @@ import java.sql.DriverManager;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
/**
@@ -53,7 +54,7 @@ public final class JDBCStateExporter implements
MetricsExporter {
result.cleanMetrics();
DriverDataSourceCache dataSourceCache =
AgentReflectionUtils.getFieldValue(shardingSphereDriverOptional.get(),
"dataSourceCache");
Map<String, DataSource> dataSourceMap =
AgentReflectionUtils.getFieldValue(dataSourceCache, "dataSourceMap");
- for (Map.Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
+ for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
ShardingSphereDataSource shardingSphereDataSource =
(ShardingSphereDataSource) entry.getValue();
ContextManager contextManager =
AgentReflectionUtils.getFieldValue(shardingSphereDataSource, "contextManager");
result.addMetric(Collections.emptyList(),
contextManager.getInstanceContext().getInstance().getState().getCurrentState().ordinal());
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
index f56ee5934b5..8966eb71203 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
@@ -36,6 +36,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Map.Entry;
/**
* TODO Rename to YamlMaskRuleConfigurationSwapper when metadata structure
adjustment completed.
@@ -52,7 +53,7 @@ public final class NewYamlMaskRuleConfigurationSwapper
implements NewYamlRuleCon
@Override
public Collection<YamlDataNode> swapToDataNodes(final
MaskRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
- for (Map.Entry<String, AlgorithmConfiguration> entry :
data.getMaskAlgorithms().entrySet()) {
+ for (Entry<String, AlgorithmConfiguration> entry :
data.getMaskAlgorithms().entrySet()) {
result.add(new
YamlDataNode(maskRuleNodePath.getNamedItem(MaskNodePath.ALGORITHMS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
index 098c109f588..3a860041cb7 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
@@ -37,6 +37,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Map.Entry;
/**
* TODO Rename YamlReadwriteSplittingRuleConfigurationSwapper when metadata
structure adjustment completed. #25485
@@ -51,7 +52,7 @@ public final class
NewYamlReadwriteSplittingRuleConfigurationSwapper implements
@Override
public Collection<YamlDataNode> swapToDataNodes(final
ReadwriteSplittingRuleConfiguration data) {
Collection<YamlDataNode> result = new LinkedHashSet<>();
- for (Map.Entry<String, AlgorithmConfiguration> entry :
data.getLoadBalancers().entrySet()) {
+ for (Entry<String, AlgorithmConfiguration> entry :
data.getLoadBalancers().entrySet()) {
result.add(new
YamlDataNode(readwriteSplittingRuleNodePath.getNamedItem(ReadwriteSplittingNodePath.LOAD_BALANCERS).getPath(entry.getKey()),
YamlEngine.marshal(algorithmSwapper.swapToYamlConfiguration(entry.getValue()))));
}
diff --git
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
index 3666cc3adf4..8f7983f80bb 100644
---
a/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
+++
b/features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/checker/ReadwriteSplittingRuleStatementChecker.java
@@ -41,7 +41,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -120,7 +120,7 @@ public final class ReadwriteSplittingRuleStatementChecker {
private static Collection<String> getDuplicated(final Collection<String>
required) {
return required.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
}
private static void checkDuplicateRuleNamesWithExistsDataSources(final
ShardingSphereDatabase database, final
Collection<ReadwriteSplittingRuleSegment> segments) {
diff --git
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
index 49d98822d1e..644b4638339 100644
---
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
+++
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/checker/ShadowRuleStatementChecker.java
@@ -31,7 +31,7 @@ import
org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -99,7 +99,7 @@ public class ShadowRuleStatementChecker {
private static Collection<String> getDuplicated(final Collection<String>
names) {
return names.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
}
private static Collection<String> getDuplicated(final Collection<String>
required, final Collection<String> current) {
diff --git
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
index 41eb45727e9..9ad4e3f5cac 100644
---
a/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
+++
b/features/shadow/distsql/handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/update/DropShadowRuleStatementUpdater.java
@@ -34,6 +34,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
@@ -89,7 +90,7 @@ public final class DropShadowRuleStatementUpdater implements
RuleDefinitionDropU
final Map<String,
ShadowTableConfiguration> toBeDroppedTables, final Map<String,
AlgorithmConfiguration> toBeDroppedShadowAlgorithms,
final String
toBeDroppedDataSourceName, final Collection<String> toBeDroppedDataSourceNames)
{
toBeDroppedDataSources.add(new
ShadowDataSourceConfiguration(toBeDroppedDataSourceName, null, null));
- for (Map.Entry<String, ShadowTableConfiguration> each :
currentRuleConfig.getTables().entrySet()) {
+ for (Entry<String, ShadowTableConfiguration> each :
currentRuleConfig.getTables().entrySet()) {
if
(toBeDroppedDataSourceNames.containsAll(each.getValue().getDataSourceNames())) {
toBeDroppedTables.put(each.getKey(), each.getValue());
}
@@ -110,7 +111,7 @@ public final class DropShadowRuleStatementUpdater
implements RuleDefinitionDropU
public ShadowRuleConfiguration buildToBeAlteredRuleConfiguration(final
ShadowRuleConfiguration currentRuleConfig, final DropShadowRuleStatement
sqlStatement) {
Map<String, ShadowTableConfiguration> tables = new LinkedHashMap<>();
Collection<String> toBeDroppedDataSourceNames =
sqlStatement.getNames();
- for (Map.Entry<String, ShadowTableConfiguration> each :
currentRuleConfig.getTables().entrySet()) {
+ for (Entry<String, ShadowTableConfiguration> each :
currentRuleConfig.getTables().entrySet()) {
if
(!toBeDroppedDataSourceNames.containsAll(each.getValue().getDataSourceNames()))
{
List<String> currentDataSources = new
LinkedList<>(each.getValue().getDataSourceNames());
currentDataSources.removeAll(toBeDroppedDataSourceNames);
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/progress/JobItemInventoryTasksProgress.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/progress/JobItemInventoryTasksProgress.java
index c4aef21a2a7..cad206aba76 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/progress/JobItemInventoryTasksProgress.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/common/job/progress/JobItemInventoryTasksProgress.java
@@ -23,6 +23,7 @@ import
org.apache.shardingsphere.data.pipeline.api.ingest.position.IngestPositio
import
org.apache.shardingsphere.data.pipeline.common.task.progress.InventoryTaskProgress;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -43,6 +44,6 @@ public final class JobItemInventoryTasksProgress {
*/
public Map<String, IngestPosition> getInventoryPosition(final String
tableName) {
Pattern pattern = Pattern.compile(String.format("%s(#\\d+)?",
tableName));
- return progresses.entrySet().stream().filter(entry ->
pattern.matcher(entry.getKey()).find()).collect(Collectors.toMap(Map.Entry::getKey,
entry -> entry.getValue().getPosition()));
+ return progresses.entrySet().stream().filter(entry ->
pattern.matcher(entry.getKey()).find()).collect(Collectors.toMap(Entry::getKey,
entry -> entry.getValue().getPosition()));
}
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/EncryptRuleConfigurationImportChecker.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/EncryptRuleConfigurationImportChecker.java
index c500aeb4b52..c13d2ef8ef5 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/EncryptRuleConfigurationImportChecker.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/EncryptRuleConfigurationImportChecker.java
@@ -30,7 +30,7 @@ import
org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
import java.util.Collection;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -57,7 +57,7 @@ public final class EncryptRuleConfigurationImportChecker {
private void checkTables(final EncryptRuleConfiguration currentRuleConfig,
final String databaseName) {
Collection<String> tableNames =
currentRuleConfig.getTables().stream().map(EncryptTableRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> duplicatedTables =
tableNames.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), ()
-> new DuplicateRuleException("ENCRYPT", databaseName, duplicatedTables));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/MaskRuleConfigurationImportChecker.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/MaskRuleConfigurationImportChecker.java
index fa630cdabae..1a0693006d4 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/MaskRuleConfigurationImportChecker.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/MaskRuleConfigurationImportChecker.java
@@ -29,7 +29,7 @@ import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Collection;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
@@ -55,7 +55,7 @@ public final class MaskRuleConfigurationImportChecker {
private void checkTables(final MaskRuleConfiguration currentRuleConfig,
final String databaseName) {
Collection<String> tableNames =
currentRuleConfig.getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList());
Collection<String> duplicatedTables =
tableNames.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), ()
-> new DuplicateRuleException("MASK", databaseName, duplicatedTables));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShadowRuleConfigurationImportChecker.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShadowRuleConfigurationImportChecker.java
index 60160b84ef6..4b659b761df 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShadowRuleConfigurationImportChecker.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShadowRuleConfigurationImportChecker.java
@@ -28,7 +28,7 @@ import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
import java.util.Collection;
import java.util.LinkedHashSet;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
/**
@@ -81,7 +81,7 @@ public final class ShadowRuleConfigurationImportChecker {
private void checkTables(final ShadowRuleConfiguration currentRuleConfig,
final String databaseName) {
Collection<String> tableNames = currentRuleConfig.getTables().keySet();
Collection<String> duplicatedTables =
tableNames.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(duplicatedTables.isEmpty(), ()
-> new DuplicateRuleException("SHADOW", databaseName, duplicatedTables));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
index 63e4570e011..360e0dd9187 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportChecker.java
@@ -36,7 +36,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
-import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -70,7 +70,7 @@ public final class ShardingRuleConfigurationImportChecker {
allLogicTables.addAll(tablesLogicTables);
allLogicTables.addAll(autoTablesLogicTables);
Set<String> duplicatedLogicTables =
allLogicTables.stream().collect(Collectors.groupingBy(each -> each,
Collectors.counting())).entrySet().stream()
- .filter(each -> each.getValue() >
1).map(Map.Entry::getKey).collect(Collectors.toSet());
+ .filter(each -> each.getValue() >
1).map(Entry::getKey).collect(Collectors.toSet());
ShardingSpherePreconditions.checkState(duplicatedLogicTables.isEmpty(), () ->
new DuplicateRuleException("sharding", databaseName, duplicatedLogicTables));
}