Skip to content

Commit

Permalink
Fix unaliasing ExchangeNode outputs
Browse files Browse the repository at this point in the history
Reintroduces separate mapping strategy for the cases of single source
and multiple sources of ExchangeNode.
The previous separation was lost when refactoring the class,
resulting in potentially creating longer mapping paths.
  • Loading branch information
kasiafi committed Jul 30, 2020
1 parent bfde029 commit 90bc42d
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,22 @@ public PlanAndMappings visitExchange(ExchangeNode node, UnaliasContext context)
}
}
}

// 2. for multiple ExchangeNode sources, if different output symbols result from the same lists of canonical input symbols, map all those outputs to the same symbol
Map<List<Symbol>, Symbol> inputsToOutputs = new HashMap<>();
for (int i = 0; i < rewrittenOutputs.size(); i++) {
ImmutableList.Builder<Symbol> inputsBuilder = ImmutableList.builder();
for (List<Symbol> inputs : rewrittenInputs) {
inputsBuilder.add(inputs.get(i));
}
List<Symbol> inputs = inputsBuilder.build();
Symbol previous = inputsToOutputs.get(inputs);
if (previous == null || rewrittenOutputs.get(i).equals(previous)) {
inputsToOutputs.put(inputs, rewrittenOutputs.get(i));
}
else {
newMapping.put(rewrittenOutputs.get(i), previous);
else {
// 2. for multiple ExchangeNode sources, if different output symbols result from the same lists of canonical input symbols, map all those outputs to the same symbol
Map<List<Symbol>, Symbol> inputsToOutputs = new HashMap<>();
for (int i = 0; i < rewrittenOutputs.size(); i++) {
ImmutableList.Builder<Symbol> inputsBuilder = ImmutableList.builder();
for (List<Symbol> inputs : rewrittenInputs) {
inputsBuilder.add(inputs.get(i));
}
List<Symbol> inputs = inputsBuilder.build();
Symbol previous = inputsToOutputs.get(inputs);
if (previous == null || rewrittenOutputs.get(i).equals(previous)) {
inputsToOutputs.put(inputs, rewrittenOutputs.get(i));
}
else {
newMapping.put(rewrittenOutputs.get(i), previous);
}
}
}

Expand Down

0 comments on commit 90bc42d

Please sign in to comment.