This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 085ce6605d842b1533e73db6d77b8c00bd932c71 Author: Dmitry Lychagin <[email protected]> AuthorDate: Mon Apr 13 16:23:54 2020 -0700 [NO ISSUE][COMP] Fix schema computation by UnionAll - user model changes: no - storage format changes: no - interface changes: no Details: - UnionAllOperator.recomputeSchema() is incorrect and might produce huge variable lists for nested UNION ALL operations. This can lead to out of memory during query compilation. Change-Id: I62a44289cc2c43f4ba6160fa5b7638503e8733fb Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/5444 Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> --- .../union/union_nested/union_nested.1.ddl.sqlpp | 48 +++++++ .../union/union_nested/union_nested.2.update.sqlpp | 22 ++++ .../union/union_nested/union_nested.3.query.sqlpp | 93 ++++++++++++++ .../results/union/union_nested/union_nested.3.adm | 138 +++++++++++++++++++++ .../test/resources/runtimets/testsuite_sqlpp.xml | 5 + .../operators/logical/UnionAllOperator.java | 40 +++--- 6 files changed, 331 insertions(+), 15 deletions(-) diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.1.ddl.sqlpp new file mode 100644 index 0000000..d881c98 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.1.ddl.sqlpp @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Test various combinations of grouping sets + */ + +drop dataverse test if exists; +create dataverse test; + +use test; + +create type tenkType as closed { + unique1 : integer, + unique2 : integer, + two : integer, + four : integer, + ten : integer, + twenty : integer, + hundred : integer, + thousand : integer, + twothousand : integer, + fivethous : integer, + tenthous : integer, + odd100 : integer, + even100 : integer, + stringu1 : string, + stringu2 : string, + string4 : string +}; + +create dataset tenk(tenkType) primary key unique2; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.2.update.sqlpp new file mode 100644 index 0000000..7128175 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.2.update.sqlpp @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +load dataset tenk using localfs ((`path`=`asterix_nc1://data/tenk.tbl`),(`format`=`delimited-text`),(`delimiter`=`|`)); \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.3.query.sqlpp new file mode 100644 index 0000000..ddd69bd --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/union/union_nested/union_nested.3.query.sqlpp @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use test; + +select two, four, ten, twenty, + sum(unique1) as agg_sum +from tenk +group by two, four, ten, twenty + +union all +select two, four, ten, twenty, + sum(unique1) as agg_sum +from tenk +group by -two as two, -four as four, -ten as ten, -twenty as twenty + +union all +select two, four, ten, twenty, + sum(unique1) as agg_sum +from tenk +group by tostring(two) as two, tostring(four) as four, tostring(ten) as ten, tostring(twenty) as twenty + +union all +select two, four, ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by two, four, ten + +union all +select two, four, ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by -two as two, -four as four, -ten as ten + +union all +select two, four, ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by tostring(two) as two, tostring(four) as four, tostring(ten) as ten + +union all +select two, four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by two, four + +union all +select two, four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by -two as two, -four as four + +union all +select two, four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by tostring(two) as two, tostring(four) as four + +union all +select two, null as four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by two + +union all +select two, null as four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by -two as two + +union all +select two, null as four, null as ten, null as twenty, + sum(unique1) as agg_sum +from tenk +group by tostring(two) as two + +order by two, four, ten, twenty; \ No newline at end of file diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/union/union_nested/union_nested.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/union/union_nested/union_nested.3.adm new file mode 100644 index 0000000..4737f9e --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/union/union_nested/union_nested.3.adm @@ -0,0 +1,138 @@ +{ "agg_sum": 25000000, "two": -1, "four": null, "ten": null, "twenty": null } +{ "agg_sum": 12502500, "two": -1, "four": -3, "ten": null, "twenty": null } +{ "agg_sum": 2504500, "two": -1, "four": -3, "ten": -9, "twenty": null } +{ "agg_sum": 2504500, "two": -1, "four": -3, "ten": -9, "twenty": -19 } +{ "agg_sum": 2498500, "two": -1, "four": -3, "ten": -7, "twenty": null } +{ "agg_sum": 2498500, "two": -1, "four": -3, "ten": -7, "twenty": -7 } +{ "agg_sum": 2502500, "two": -1, "four": -3, "ten": -5, "twenty": null } +{ "agg_sum": 2502500, "two": -1, "four": -3, "ten": -5, "twenty": -15 } +{ "agg_sum": 2496500, "two": -1, "four": -3, "ten": -3, "twenty": null } +{ "agg_sum": 2496500, "two": -1, "four": -3, "ten": -3, "twenty": -3 } +{ "agg_sum": 2500500, "two": -1, "four": -3, "ten": -1, "twenty": null } +{ "agg_sum": 2500500, "two": -1, "four": -3, "ten": -1, "twenty": -11 } +{ "agg_sum": 12497500, "two": -1, "four": -1, "ten": null, "twenty": null } +{ "agg_sum": 2499500, "two": -1, "four": -1, "ten": -9, "twenty": null } +{ "agg_sum": 2499500, "two": -1, "four": -1, "ten": -9, "twenty": -9 } +{ "agg_sum": 2503500, "two": -1, "four": -1, "ten": -7, "twenty": null } +{ "agg_sum": 2503500, "two": -1, "four": -1, "ten": -7, "twenty": -17 } +{ "agg_sum": 2497500, "two": -1, "four": -1, "ten": -5, "twenty": null } +{ "agg_sum": 2497500, "two": -1, "four": -1, "ten": -5, "twenty": -5 } +{ "agg_sum": 2501500, "two": -1, "four": -1, "ten": -3, "twenty": null } +{ "agg_sum": 2501500, "two": -1, "four": -1, "ten": -3, "twenty": -13 } +{ "agg_sum": 2495500, "two": -1, "four": -1, "ten": -1, "twenty": null } +{ "agg_sum": 2495500, "two": -1, "four": -1, "ten": -1, "twenty": -1 } +{ "agg_sum": 24995000, "two": 0, "four": null, "ten": null, "twenty": null } +{ "agg_sum": 24995000, "two": 0, "four": null, "ten": null, "twenty": null } +{ "agg_sum": 12500000, "two": 0, "four": -2, "ten": null, "twenty": null } +{ "agg_sum": 2504000, "two": 0, "four": -2, "ten": -8, "twenty": null } +{ "agg_sum": 2504000, "two": 0, "four": -2, "ten": -8, "twenty": -18 } +{ "agg_sum": 2498000, "two": 0, "four": -2, "ten": -6, "twenty": null } +{ "agg_sum": 2498000, "two": 0, "four": -2, "ten": -6, "twenty": -6 } +{ "agg_sum": 2502000, "two": 0, "four": -2, "ten": -4, "twenty": null } +{ "agg_sum": 2502000, "two": 0, "four": -2, "ten": -4, "twenty": -14 } +{ "agg_sum": 2496000, "two": 0, "four": -2, "ten": -2, "twenty": null } +{ "agg_sum": 2496000, "two": 0, "four": -2, "ten": -2, "twenty": -2 } +{ "agg_sum": 2500000, "two": 0, "four": -2, "ten": 0, "twenty": null } +{ "agg_sum": 2500000, "two": 0, "four": -2, "ten": 0, "twenty": -10 } +{ "agg_sum": 12495000, "two": 0, "four": 0, "ten": null, "twenty": null } +{ "agg_sum": 12495000, "two": 0, "four": 0, "ten": null, "twenty": null } +{ "agg_sum": 2499000, "two": 0, "four": 0, "ten": -8, "twenty": null } +{ "agg_sum": 2499000, "two": 0, "four": 0, "ten": -8, "twenty": -8 } +{ "agg_sum": 2503000, "two": 0, "four": 0, "ten": -6, "twenty": null } +{ "agg_sum": 2503000, "two": 0, "four": 0, "ten": -6, "twenty": -16 } +{ "agg_sum": 2497000, "two": 0, "four": 0, "ten": -4, "twenty": null } +{ "agg_sum": 2497000, "two": 0, "four": 0, "ten": -4, "twenty": -4 } +{ "agg_sum": 2501000, "two": 0, "four": 0, "ten": -2, "twenty": null } +{ "agg_sum": 2501000, "two": 0, "four": 0, "ten": -2, "twenty": -12 } +{ "agg_sum": 2495000, "two": 0, "four": 0, "ten": 0, "twenty": null } +{ "agg_sum": 2495000, "two": 0, "four": 0, "ten": 0, "twenty": null } +{ "agg_sum": 2495000, "two": 0, "four": 0, "ten": 0, "twenty": 0 } +{ "agg_sum": 2495000, "two": 0, "four": 0, "ten": 0, "twenty": 0 } +{ "agg_sum": 2501000, "two": 0, "four": 0, "ten": 2, "twenty": null } +{ "agg_sum": 2501000, "two": 0, "four": 0, "ten": 2, "twenty": 12 } +{ "agg_sum": 2497000, "two": 0, "four": 0, "ten": 4, "twenty": null } +{ "agg_sum": 2497000, "two": 0, "four": 0, "ten": 4, "twenty": 4 } +{ "agg_sum": 2503000, "two": 0, "four": 0, "ten": 6, "twenty": null } +{ "agg_sum": 2503000, "two": 0, "four": 0, "ten": 6, "twenty": 16 } +{ "agg_sum": 2499000, "two": 0, "four": 0, "ten": 8, "twenty": null } +{ "agg_sum": 2499000, "two": 0, "four": 0, "ten": 8, "twenty": 8 } +{ "agg_sum": 12500000, "two": 0, "four": 2, "ten": null, "twenty": null } +{ "agg_sum": 2500000, "two": 0, "four": 2, "ten": 0, "twenty": null } +{ "agg_sum": 2500000, "two": 0, "four": 2, "ten": 0, "twenty": 10 } +{ "agg_sum": 2496000, "two": 0, "four": 2, "ten": 2, "twenty": null } +{ "agg_sum": 2496000, "two": 0, "four": 2, "ten": 2, "twenty": 2 } +{ "agg_sum": 2502000, "two": 0, "four": 2, "ten": 4, "twenty": null } +{ "agg_sum": 2502000, "two": 0, "four": 2, "ten": 4, "twenty": 14 } +{ "agg_sum": 2498000, "two": 0, "four": 2, "ten": 6, "twenty": null } +{ "agg_sum": 2498000, "two": 0, "four": 2, "ten": 6, "twenty": 6 } +{ "agg_sum": 2504000, "two": 0, "four": 2, "ten": 8, "twenty": null } +{ "agg_sum": 2504000, "two": 0, "four": 2, "ten": 8, "twenty": 18 } +{ "agg_sum": 25000000, "two": 1, "four": null, "ten": null, "twenty": null } +{ "agg_sum": 12497500, "two": 1, "four": 1, "ten": null, "twenty": null } +{ "agg_sum": 2495500, "two": 1, "four": 1, "ten": 1, "twenty": null } +{ "agg_sum": 2495500, "two": 1, "four": 1, "ten": 1, "twenty": 1 } +{ "agg_sum": 2501500, "two": 1, "four": 1, "ten": 3, "twenty": null } +{ "agg_sum": 2501500, "two": 1, "four": 1, "ten": 3, "twenty": 13 } +{ "agg_sum": 2497500, "two": 1, "four": 1, "ten": 5, "twenty": null } +{ "agg_sum": 2497500, "two": 1, "four": 1, "ten": 5, "twenty": 5 } +{ "agg_sum": 2503500, "two": 1, "four": 1, "ten": 7, "twenty": null } +{ "agg_sum": 2503500, "two": 1, "four": 1, "ten": 7, "twenty": 17 } +{ "agg_sum": 2499500, "two": 1, "four": 1, "ten": 9, "twenty": null } +{ "agg_sum": 2499500, "two": 1, "four": 1, "ten": 9, "twenty": 9 } +{ "agg_sum": 12502500, "two": 1, "four": 3, "ten": null, "twenty": null } +{ "agg_sum": 2500500, "two": 1, "four": 3, "ten": 1, "twenty": null } +{ "agg_sum": 2500500, "two": 1, "four": 3, "ten": 1, "twenty": 11 } +{ "agg_sum": 2496500, "two": 1, "four": 3, "ten": 3, "twenty": null } +{ "agg_sum": 2496500, "two": 1, "four": 3, "ten": 3, "twenty": 3 } +{ "agg_sum": 2502500, "two": 1, "four": 3, "ten": 5, "twenty": null } +{ "agg_sum": 2502500, "two": 1, "four": 3, "ten": 5, "twenty": 15 } +{ "agg_sum": 2498500, "two": 1, "four": 3, "ten": 7, "twenty": null } +{ "agg_sum": 2498500, "two": 1, "four": 3, "ten": 7, "twenty": 7 } +{ "agg_sum": 2504500, "two": 1, "four": 3, "ten": 9, "twenty": null } +{ "agg_sum": 2504500, "two": 1, "four": 3, "ten": 9, "twenty": 19 } +{ "agg_sum": 24995000, "two": "0", "four": null, "ten": null, "twenty": null } +{ "agg_sum": 12495000, "two": "0", "four": "0", "ten": null, "twenty": null } +{ "agg_sum": 2495000, "two": "0", "four": "0", "ten": "0", "twenty": null } +{ "agg_sum": 2495000, "two": "0", "four": "0", "ten": "0", "twenty": "0" } +{ "agg_sum": 2501000, "two": "0", "four": "0", "ten": "2", "twenty": null } +{ "agg_sum": 2501000, "two": "0", "four": "0", "ten": "2", "twenty": "12" } +{ "agg_sum": 2497000, "two": "0", "four": "0", "ten": "4", "twenty": null } +{ "agg_sum": 2497000, "two": "0", "four": "0", "ten": "4", "twenty": "4" } +{ "agg_sum": 2503000, "two": "0", "four": "0", "ten": "6", "twenty": null } +{ "agg_sum": 2503000, "two": "0", "four": "0", "ten": "6", "twenty": "16" } +{ "agg_sum": 2499000, "two": "0", "four": "0", "ten": "8", "twenty": null } +{ "agg_sum": 2499000, "two": "0", "four": "0", "ten": "8", "twenty": "8" } +{ "agg_sum": 12500000, "two": "0", "four": "2", "ten": null, "twenty": null } +{ "agg_sum": 2500000, "two": "0", "four": "2", "ten": "0", "twenty": null } +{ "agg_sum": 2500000, "two": "0", "four": "2", "ten": "0", "twenty": "10" } +{ "agg_sum": 2496000, "two": "0", "four": "2", "ten": "2", "twenty": null } +{ "agg_sum": 2496000, "two": "0", "four": "2", "ten": "2", "twenty": "2" } +{ "agg_sum": 2502000, "two": "0", "four": "2", "ten": "4", "twenty": null } +{ "agg_sum": 2502000, "two": "0", "four": "2", "ten": "4", "twenty": "14" } +{ "agg_sum": 2498000, "two": "0", "four": "2", "ten": "6", "twenty": null } +{ "agg_sum": 2498000, "two": "0", "four": "2", "ten": "6", "twenty": "6" } +{ "agg_sum": 2504000, "two": "0", "four": "2", "ten": "8", "twenty": null } +{ "agg_sum": 2504000, "two": "0", "four": "2", "ten": "8", "twenty": "18" } +{ "agg_sum": 25000000, "two": "1", "four": null, "ten": null, "twenty": null } +{ "agg_sum": 12497500, "two": "1", "four": "1", "ten": null, "twenty": null } +{ "agg_sum": 2495500, "two": "1", "four": "1", "ten": "1", "twenty": null } +{ "agg_sum": 2495500, "two": "1", "four": "1", "ten": "1", "twenty": "1" } +{ "agg_sum": 2501500, "two": "1", "four": "1", "ten": "3", "twenty": null } +{ "agg_sum": 2501500, "two": "1", "four": "1", "ten": "3", "twenty": "13" } +{ "agg_sum": 2497500, "two": "1", "four": "1", "ten": "5", "twenty": null } +{ "agg_sum": 2497500, "two": "1", "four": "1", "ten": "5", "twenty": "5" } +{ "agg_sum": 2503500, "two": "1", "four": "1", "ten": "7", "twenty": null } +{ "agg_sum": 2503500, "two": "1", "four": "1", "ten": "7", "twenty": "17" } +{ "agg_sum": 2499500, "two": "1", "four": "1", "ten": "9", "twenty": null } +{ "agg_sum": 2499500, "two": "1", "four": "1", "ten": "9", "twenty": "9" } +{ "agg_sum": 12502500, "two": "1", "four": "3", "ten": null, "twenty": null } +{ "agg_sum": 2500500, "two": "1", "four": "3", "ten": "1", "twenty": null } +{ "agg_sum": 2500500, "two": "1", "four": "3", "ten": "1", "twenty": "11" } +{ "agg_sum": 2496500, "two": "1", "four": "3", "ten": "3", "twenty": null } +{ "agg_sum": 2496500, "two": "1", "four": "3", "ten": "3", "twenty": "3" } +{ "agg_sum": 2502500, "two": "1", "four": "3", "ten": "5", "twenty": null } +{ "agg_sum": 2502500, "two": "1", "four": "3", "ten": "5", "twenty": "15" } +{ "agg_sum": 2498500, "two": "1", "four": "3", "ten": "7", "twenty": null } +{ "agg_sum": 2498500, "two": "1", "four": "3", "ten": "7", "twenty": "7" } +{ "agg_sum": 2504500, "two": "1", "four": "3", "ten": "9", "twenty": null } +{ "agg_sum": 2504500, "two": "1", "four": "3", "ten": "9", "twenty": "19" } diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml index a578690..8fbff50 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml @@ -12349,6 +12349,11 @@ </compilation-unit> </test-case> <test-case FilePath="union"> + <compilation-unit name="union_nested"> + <output-dir compare="Text">union_nested</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="union"> <compilation-unit name="union_orderby"> <output-dir compare="Text">union_orderby</output-dir> </compilation-unit> diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/UnionAllOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/UnionAllOperator.java index 9defb4f..d394e2f 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/UnionAllOperator.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/UnionAllOperator.java @@ -19,6 +19,7 @@ package org.apache.hyracks.algebricks.core.algebra.operators.logical; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; @@ -77,25 +78,34 @@ public class UnionAllOperator extends AbstractLogicalOperator { @Override public void recomputeSchema() { - schema = new ArrayList<LogicalVariable>(); - for (LogicalVariable v1 : inputs.get(0).getValue().getSchema()) { - for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> t : varMap) { - if (t.first.equals(v1)) { - schema.add(t.third); - } else { - schema.add(v1); - } + LinkedHashSet<LogicalVariable> outVarSet = new LinkedHashSet<>(); + for (int i = 0, ln = inputs.size(); i < ln; i++) { + for (LogicalVariable inVar : inputs.get(i).getValue().getSchema()) { + LogicalVariable outVar = findOutputVar(inVar, i); + outVarSet.add(outVar != null ? outVar : inVar); } } - for (LogicalVariable v2 : inputs.get(1).getValue().getSchema()) { - for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> t : varMap) { - if (t.second.equals(v2)) { - schema.add(t.third); - } else { - schema.add(v2); - } + schema = new ArrayList<>(outVarSet); + } + + private LogicalVariable findOutputVar(LogicalVariable inputVar, int inputIdx) { + for (Triple<LogicalVariable, LogicalVariable, LogicalVariable> t : varMap) { + LogicalVariable testVar; + switch (inputIdx) { + case 0: + testVar = t.first; + break; + case 1: + testVar = t.second; + break; + default: + throw new IllegalArgumentException(String.valueOf(inputIdx)); + } + if (inputVar.equals(testVar)) { + return t.third; } } + return null; } @Override
