aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java')
-rw-r--r--subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java38
1 files changed, 26 insertions, 12 deletions
diff --git a/subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java b/subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java
index 301b757d..1f6a01ae 100644
--- a/subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java
+++ b/subprojects/interpreter-rete/src/main/java/tools/refinery/interpreter/rete/network/NodeFactory.java
@@ -20,6 +20,7 @@ import tools.refinery.interpreter.matchers.tuple.Tuples;
20import tools.refinery.interpreter.rete.aggregation.ColumnAggregatorNode; 20import tools.refinery.interpreter.rete.aggregation.ColumnAggregatorNode;
21import tools.refinery.interpreter.rete.aggregation.CountNode; 21import tools.refinery.interpreter.rete.aggregation.CountNode;
22import tools.refinery.interpreter.rete.aggregation.IAggregatorNode; 22import tools.refinery.interpreter.rete.aggregation.IAggregatorNode;
23import tools.refinery.interpreter.rete.aggregation.LeftJoinNode;
23import tools.refinery.interpreter.rete.aggregation.timely.FaithfulParallelTimelyColumnAggregatorNode; 24import tools.refinery.interpreter.rete.aggregation.timely.FaithfulParallelTimelyColumnAggregatorNode;
24import tools.refinery.interpreter.rete.aggregation.timely.FaithfulSequentialTimelyColumnAggregatorNode; 25import tools.refinery.interpreter.rete.aggregation.timely.FaithfulSequentialTimelyColumnAggregatorNode;
25import tools.refinery.interpreter.rete.aggregation.timely.FirstOnlyParallelTimelyColumnAggregatorNode; 26import tools.refinery.interpreter.rete.aggregation.timely.FirstOnlyParallelTimelyColumnAggregatorNode;
@@ -72,18 +73,25 @@ class NodeFactory {
72 return parentNode.constructIndex(toMask(recipe.getMask()), traces); 73 return parentNode.constructIndex(toMask(recipe.getMask()), traces);
73 // already traced 74 // already traced
74 } else if (recipe instanceof AggregatorIndexerRecipe) { 75 } else if (recipe instanceof AggregatorIndexerRecipe) {
75 int indexOfAggregateResult = recipe.getParent().getArity(); 76 int indexOfAggregateResult = recipe.getParent().getArity();
76 int resultPosition = recipe.getMask().getSourceIndices().lastIndexOf(indexOfAggregateResult); 77 int resultPosition = recipe.getMask().getSourceIndices().lastIndexOf(indexOfAggregateResult);
77 78
78 IAggregatorNode aggregatorNode = (IAggregatorNode) parentNode; 79 IAggregatorNode aggregatorNode = (IAggregatorNode) parentNode;
79 final Indexer result = (resultPosition == -1) ? aggregatorNode.getAggregatorOuterIndexer() 80 final Indexer result = (resultPosition == -1) ? aggregatorNode.getAggregatorOuterIndexer()
80 : aggregatorNode.getAggregatorOuterIdentityIndexer(resultPosition); 81 : aggregatorNode.getAggregatorOuterIdentityIndexer(resultPosition);
81 82
82 for (TraceInfo traceInfo : traces) 83 for (TraceInfo traceInfo : traces)
83 result.assignTraceInfo(traceInfo); 84 result.assignTraceInfo(traceInfo);
84 return result; 85 return result;
85 } else 86 } else if (recipe instanceof OuterJoinIndexerRecipe) {
86 throw new IllegalArgumentException("Unkown Indexer recipe: " + recipe); 87 var leftJoinNode = (LeftJoinNode) parentNode;
88 var result = leftJoinNode.getOuterIndexer();
89 for (TraceInfo traceInfo : traces)
90 result.assignTraceInfo(traceInfo);
91 return result;
92 } else {
93 throw new IllegalArgumentException("Unkown Indexer recipe: " + recipe);
94 }
87 } 95 }
88 96
89 /** 97 /**
@@ -134,6 +142,8 @@ class NodeFactory {
134 return instantiateNode(reteContainer, (CountAggregatorRecipe) recipe); 142 return instantiateNode(reteContainer, (CountAggregatorRecipe) recipe);
135 if (recipe instanceof SingleColumnAggregatorRecipe) 143 if (recipe instanceof SingleColumnAggregatorRecipe)
136 return instantiateNode(reteContainer, (SingleColumnAggregatorRecipe) recipe); 144 return instantiateNode(reteContainer, (SingleColumnAggregatorRecipe) recipe);
145 if (recipe instanceof OuterJoinNodeRecipe outerJoinNodeRecipe)
146 return instantiateNode(reteContainer, outerJoinNodeRecipe);
137 if (recipe instanceof DiscriminatorDispatcherRecipe) 147 if (recipe instanceof DiscriminatorDispatcherRecipe)
138 return instantiateNode(reteContainer, (DiscriminatorDispatcherRecipe) recipe); 148 return instantiateNode(reteContainer, (DiscriminatorDispatcherRecipe) recipe);
139 if (recipe instanceof DiscriminatorBucketRecipe) 149 if (recipe instanceof DiscriminatorBucketRecipe)
@@ -246,6 +256,10 @@ class NodeFactory {
246 } 256 }
247 } 257 }
248 258
259 private Supplier instantiateNode(ReteContainer reteContainer, OuterJoinNodeRecipe recipe) {
260 return new LeftJoinNode(reteContainer, recipe.getDefaultValue());
261 }
262
249 private Supplier instantiateNode(ReteContainer reteContainer, TransitiveClosureRecipe recipe) { 263 private Supplier instantiateNode(ReteContainer reteContainer, TransitiveClosureRecipe recipe) {
250 return new TransitiveClosureNode(reteContainer); 264 return new TransitiveClosureNode(reteContainer);
251 } 265 }