Remove identity-collection use in TranslationMap
@@ -15,7 +15,6 @@ package com.facebook.presto.sql.planner;
import com.facebook.presto.spi.type.Type;
import com.facebook.presto.sql.analyzer.Analysis;
-import com.facebook.presto.sql.analyzer.NodeRefCollections;
import com.facebook.presto.sql.analyzer.ResolvedField;
import com.facebook.presto.sql.tree.Cast;
import com.facebook.presto.sql.tree.DereferenceExpression;
@@ -27,7 +26,6 @@ import com.facebook.presto.sql.tree.Identifier;
import com.facebook.presto.sql.tree.LambdaArgumentDeclaration;
import com.facebook.presto.sql.tree.LambdaExpression;
import com.facebook.presto.sql.tree.NodeRef;
-import com.facebook.presto.util.maps.IdentityLinkedHashMap;
import com.google.common.collect.ImmutableList;
import java.util.HashMap;
@@ -47,7 +45,7 @@ class TranslationMap
// all expressions are rewritten in terms of fields declared by this relation plan
private final RelationPlan rewriteBase;
private final Analysis analysis;
- private final IdentityLinkedHashMap<LambdaArgumentDeclaration, Symbol> lambdaDeclarationToSymbolMap;
+ private final Map<NodeRef<LambdaArgumentDeclaration>, Symbol> lambdaDeclarationToSymbolMap;
// current mappings of underlying field -> symbol for translating direct field references
private final Symbol[] fieldSymbols;
@@ -57,11 +55,6 @@ class TranslationMap
private final Map<Expression, Expression> expressionToExpressions = new HashMap<>();
public TranslationMap(RelationPlan rewriteBase, Analysis analysis, Map<NodeRef<LambdaArgumentDeclaration>, Symbol> lambdaDeclarationToSymbolMap)
- {
- this(rewriteBase, analysis, NodeRefCollections.toIdentityMap(lambdaDeclarationToSymbolMap));
- }
-
- public TranslationMap(RelationPlan rewriteBase, Analysis analysis, IdentityLinkedHashMap<LambdaArgumentDeclaration, Symbol> lambdaDeclarationToSymbolMap)
{
this.rewriteBase = requireNonNull(rewriteBase, "rewriteBase is null");
this.analysis = requireNonNull(analysis, "analysis is null");
@@ -80,7 +73,7 @@ class TranslationMap
return analysis;
}
- public IdentityLinkedHashMap<LambdaArgumentDeclaration, Symbol> getLambdaDeclarationToSymbolMap()
+ public Map<NodeRef<LambdaArgumentDeclaration>, Symbol> getLambdaDeclarationToSymbolMap()
{
return lambdaDeclarationToSymbolMap;
}
@@ -247,7 +240,7 @@ class TranslationMap
{
LambdaArgumentDeclaration referencedLambdaArgumentDeclaration = analysis.getLambdaArgumentReference(node);
if (referencedLambdaArgumentDeclaration != null) {
- Symbol symbol = lambdaDeclarationToSymbolMap.get(referencedLambdaArgumentDeclaration);
+ Symbol symbol = lambdaDeclarationToSymbolMap.get(NodeRef.of(referencedLambdaArgumentDeclaration));
return coerceIfNecessary(node, symbol.toSymbolReference());
}
else {
@@ -285,7 +278,8 @@ class TranslationMap
ImmutableList.Builder<LambdaArgumentDeclaration> newArguments = ImmutableList.builder();
for (LambdaArgumentDeclaration argument : node.getArguments()) {
- newArguments.add(new LambdaArgumentDeclaration(lambdaDeclarationToSymbolMap.get(argument).getName()));
+ Symbol symbol = lambdaDeclarationToSymbolMap.get(NodeRef.of(argument));
+ newArguments.add(new LambdaArgumentDeclaration(symbol.getName()));
}
Expression rewrittenBody = treeRewriter.rewrite(node.getBody(), null);
return new LambdaExpression(newArguments.build(), rewrittenBody);
