From 5709c8ac7ee0f7de4c66a9139e0080fcefb896bf Mon Sep 17 00:00:00 2001 From: Karol Sobczak Date: Fri, 5 Jun 2020 15:07:41 +0200 Subject: [PATCH] Use ImmutableMap collector in Predicte Push Down --- .../sql/planner/optimizations/PredicatePushDown.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/PredicatePushDown.java b/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/PredicatePushDown.java index e0c9f8e016f21..70b0e2ef43565 100644 --- a/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/PredicatePushDown.java +++ b/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/PredicatePushDown.java @@ -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; @@ -309,7 +310,7 @@ public PlanNode visitGroupId(GroupIdNode node, RewriteContext contex { Map 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 pushdownEligiblePredicate = conjunct -> commonGroupingSymbolMapping.keySet().containsAll(SymbolsExtractor.extractUnique(conjunct)); @@ -460,12 +461,12 @@ public PlanNode visitJoin(JoinNode node, RewriteContext 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 equiJoinClauses = new ArrayList<>(); @@ -676,12 +677,12 @@ public PlanNode visitSpatialJoin(SpatialJoinNode node, RewriteContext 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());