You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jin xing (JIRA)" <ji...@apache.org> on 2019/07/30 03:58:00 UTC
[jira] [Commented] (CALCITE-3211) List of MutableRel may fail to be
identified by SubstitutionVisitor during matching
[ https://issues.apache.org/jira/browse/CALCITE-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16895748#comment-16895748 ]
jin xing commented on CALCITE-3211:
-----------------------------------
Thanks a lot [~julianhyde]
"People should not call {{Lists.transform}} if they are going to use the list more than once and expect the same results" -- This is true.
I updated the PR according to your comment, it's great if you can take a look when you have time :)
> List of MutableRel may fail to be identified by SubstitutionVisitor during matching
> -----------------------------------------------------------------------------------
>
> Key: CALCITE-3211
> URL: https://issues.apache.org/jira/browse/CALCITE-3211
> Project: Calcite
> Issue Type: Bug
> Reporter: jin xing
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Current implementation of {{MutableRels::toMutables}} is as below:
> {code:java}
> private static List<MutableRel> toMutables(List<RelNode> nodes) {
> return Lists.transform(nodes, MutableRels::toMutable);
> }
> {code}
> Thus every time we {{get}} from the result list, a new {{MutableRel}} will be created:
> {code:java}
> private static class TransformingRandomAccessList<F, T> extends AbstractList<T>
> implements RandomAccess, Serializable {
> final List<F> fromList;
> final Function<? super F, ? extends T> function;
> TransformingRandomAccessList(List<F> fromList, Function<? super F, ? extends T> function) {
> this.fromList = checkNotNull(fromList);
> this.function = checkNotNull(function);
> }
> @Override
> public T get(int index) {
> return function.apply(fromList.get(index));
> }
> ......
> {code}
> As a result, https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java#L514 {{SubstitutionVisitor}} will fail to check whether a node has been met/matched before
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)