Skip to content

Commit

Permalink
Use ImmutableMap collector in Predicte Push Down
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Jun 8, 2020
1 parent 77273a2 commit 5709c8a
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static io.prestosql.SystemSessionProperties.isEnableDynamicFiltering;
import static io.prestosql.SystemSessionProperties.isPredicatePushdownUseTableProperties;
import static io.prestosql.sql.DynamicFilters.createDynamicFilterExpression;
Expand Down Expand Up @@ -309,7 +310,7 @@ public PlanNode visitGroupId(GroupIdNode node, RewriteContext<Expression> contex
{
Map<Symbol, SymbolReference> commonGroupingSymbolMapping = node.getGroupingColumns().entrySet().stream()
.filter(entry -> node.getCommonGroupingColumns().contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().toSymbolReference()));
.collect(toImmutableMap(Map.Entry::getKey, entry -> entry.getValue().toSymbolReference()));

Predicate<Expression> pushdownEligiblePredicate = conjunct -> commonGroupingSymbolMapping.keySet().containsAll(SymbolsExtractor.extractUnique(conjunct));

Expand Down Expand Up @@ -460,12 +461,12 @@ public PlanNode visitJoin(JoinNode node, RewriteContext<Expression> context)
Assignments.Builder leftProjections = Assignments.builder();
leftProjections.putAll(node.getLeft()
.getOutputSymbols().stream()
.collect(Collectors.toMap(key -> key, Symbol::toSymbolReference)));
.collect(toImmutableMap(key -> key, Symbol::toSymbolReference)));

Assignments.Builder rightProjections = Assignments.builder();
rightProjections.putAll(node.getRight()
.getOutputSymbols().stream()
.collect(Collectors.toMap(key -> key, Symbol::toSymbolReference)));
.collect(toImmutableMap(key -> key, Symbol::toSymbolReference)));

// Create new projections for the new join clauses
List<JoinNode.EquiJoinClause> equiJoinClauses = new ArrayList<>();
Expand Down Expand Up @@ -676,12 +677,12 @@ public PlanNode visitSpatialJoin(SpatialJoinNode node, RewriteContext<Expression
Assignments.Builder leftProjections = Assignments.builder();
leftProjections.putAll(node.getLeft()
.getOutputSymbols().stream()
.collect(Collectors.toMap(key -> key, Symbol::toSymbolReference)));
.collect(toImmutableMap(key -> key, Symbol::toSymbolReference)));

Assignments.Builder rightProjections = Assignments.builder();
rightProjections.putAll(node.getRight()
.getOutputSymbols().stream()
.collect(Collectors.toMap(key -> key, Symbol::toSymbolReference)));
.collect(toImmutableMap(key -> key, Symbol::toSymbolReference)));

leftSource = new ProjectNode(idAllocator.getNextId(), leftSource, leftProjections.build());
rightSource = new ProjectNode(idAllocator.getNextId(), rightSource, rightProjections.build());
Expand Down

0 comments on commit 5709c8a

Please sign in to comment.