@@ -0,0 +1,2315 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.sql.analyzer;%0A%0Aimport com.facebook.presto.sql.tree.Node;%0Aimport com.facebook.presto.sql.tree.NodeRef;%0Aimport com.facebook.presto.util.maps.IdentityLinkedHashMap;%0A%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0Aimport java.util.Map.Entry;%0Aimport java.util.Set;%0A%0Aimport static com.google.common.collect.ImmutableSet.toImmutableSet;%0Aimport static java.util.Collections.newSetFromMap;%0A%0A/**%0A * Temporary class facilitating conversions from/to identity-based Maps and Sets%0A */%0Apublic class NodeRefCollections%0A%7B%0A    public static %3CK extends Node, V%3E IdentityLinkedHashMap%3CK, V%3E toIdentityMap(Map%3CNodeRef%3CK%3E, V%3E map)%0A    %7B%0A        IdentityLinkedHashMap%3CK, V%3E result = new IdentityLinkedHashMap%3C%3E();%0A        for (Entry%3CNodeRef%3CK%3E, V%3E entry : map.entrySet()) %7B%0A            result.put(entry.getKey().getNode(), entry.getValue());%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static %3CK extends Node, V%3E Map%3CNodeRef%3CK%3E, V%3E fromIdentityMap(IdentityLinkedHashMap%3CK, V%3E map)%0A    %7B%0A        Map%3CNodeRef%3CK%3E, V%3E result = new LinkedHashMap%3C%3E();%0A        for (Entry%3CK, V%3E entry : map.entrySet()) %7B%0A            result.put(NodeRef.of(entry.getKey()), entry.getValue());%0A        %7D%0A        return result;%0A    %7D%0A%0A    public static %3CT extends Node%3E Set%3CT%3E toIdentitySet(Set%3CNodeRef%3CT%3E%3E set)%0A    %7B%0A        Set%3CT%3E result = newSetFromMap(new IdentityLinkedHashMap%3C%3E());%0A        set.stream()%0A                .map(NodeRef::getNode)%0A                .forEach(result::add);%0A        return result;%0A    %7D%0A%0A    public static %3CT extends Node%3E Set%3CNodeRef%3CT%3E%3E fromIdentitySet(Set%3CT%3E set)%0A    %7B%0A        return set.stream()%0A                .map(NodeRef::of)%0A                .collect(toImmutableSet());%0A    %7D%0A%0A    private NodeRefCollections()%0A    %7B%0A    %7D%0A%7D%0A

Implement temporary conversion methods from/to identity-collections