This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 4e35795238c Replace stream with loop in ShardingConditions (#20546)
4e35795238c is described below

commit 4e35795238c27ee885cc247d567c008d6e92de5e
Author: 吴伟杰 <[email protected]>
AuthorDate: Fri Aug 26 14:06:26 2022 +0800

    Replace stream with loop in ShardingConditions (#20546)
---
 .../sharding/route/engine/condition/ShardingConditions.java        | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditions.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditions.java
index f9cab7d55f2..3a69ab19372 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditions.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditions.java
@@ -37,12 +37,12 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.util.SafeNumberOperationU
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * Sharding conditions.
@@ -121,7 +121,10 @@ public final class ShardingConditions {
     private boolean isSubqueryContainsShardingCondition(final 
List<ShardingCondition> conditions, final SQLStatementContext<?> 
sqlStatementContext) {
         Collection<SelectStatement> selectStatements = 
getSelectStatements(sqlStatementContext);
         if (selectStatements.size() > 1) {
-            Map<Integer, List<ShardingCondition>> startIndexShardingConditions 
= 
conditions.stream().collect(Collectors.groupingBy(ShardingCondition::getStartIndex));
+            Map<Integer, List<ShardingCondition>> startIndexShardingConditions 
= new HashMap<>();
+            for (ShardingCondition each : conditions) {
+                
startIndexShardingConditions.computeIfAbsent(each.getStartIndex(), unused -> 
new LinkedList<>()).add(each);
+            }
             for (SelectStatement each : selectStatements) {
                 if (each.getFrom() instanceof SubqueryTableSegment) {
                     continue;

Reply via email to