修复双重循环中间定义的变量未正确聚合的BUG

This commit is contained in:
mxd 2019-11-03 12:38:48 +08:00
parent 942f87d800
commit 9d629edba3
3 changed files with 3 additions and 3 deletions

View File

@ -168,7 +168,7 @@ public class Spider {
if(executor instanceof LoopExecutor){
variables.put(LoopExecutor.LOOP_NODE_KEY + node.getNodeId(), treeNode);
variables.put(LoopExecutor.LOOP_NODE_KEY, treeNode);
variables.put(LoopExecutor.BEFORE_LOOP_VARIABLE, variables);
variables.put(LoopExecutor.BEFORE_LOOP_VARIABLE + node.getNodeId(), variables);
variables.put(LoopJoinExecutor.VARIABLE_CONTEXT + node.getNodeId(), new LinkedBlockingQueue<>());
}
List<Runnable> runnables = new ArrayList<>();

View File

@ -17,7 +17,7 @@ public class LoopExecutor implements ShapeExecutor{
public static final String LOOP_NODE_KEY = "__loop_node_";
public static final String BEFORE_LOOP_VARIABLE = "__loop_before_variable";
public static final String BEFORE_LOOP_VARIABLE = "__loop_before_variable_";
@Override
public void execute(SpiderNode node, SpiderContext context, Map<String,Object> variables) {

View File

@ -42,7 +42,7 @@ public class LoopJoinExecutor implements ShapeExecutor {
if(treeNode != null){
boolean isDone = treeNode.isDone();
if(isDone){
Map<String, Object> beforeLoopVariable = (Map<String, Object>) variables.get(LoopExecutor.BEFORE_LOOP_VARIABLE);
Map<String, Object> beforeLoopVariable = (Map<String, Object>) variables.get(LoopExecutor.BEFORE_LOOP_VARIABLE + joinNodeId);
variableCollection.stream()
.flatMap(map -> map.entrySet().stream())
.collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.mapping(Map.Entry::getValue, Collectors.toList())))