You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2019/07/29 18:28:00 UTC
[jira] [Commented] (CALCITE-3211) MutableRel returned from
MutableRels::toMutables 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=16895507#comment-16895507 ]
Julian Hyde commented on CALCITE-3211:
--------------------------------------
Sounds right. People should not call {{Lists.transform}} if they are going to use the list more than once and expect the same results.
As an aside, {{toMutables}} is a private method with no javadoc. As such, there should be no expectations about its behavior by developers. Also, it should not be referenced in the title of a bug report. Feel free to change or remove the method if it is not doing what you want.
> MutableRel returned from MutableRels::toMutables 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)