You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2023/04/20 15:07:00 UTC

[jira] [Updated] (CALCITE-5563) Reduce loops to optimize RelSubset#getParents and RelSubset#getParentSubsets

     [ https://issues.apache.org/jira/browse/CALCITE-5563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ruben Q L updated CALCITE-5563:
-------------------------------
    Summary: Reduce loops to optimize RelSubset#getParents and RelSubset#getParentSubsets  (was: Reduce loops to improve RelSubset)

> Reduce loops to optimize RelSubset#getParents and RelSubset#getParentSubsets
> ----------------------------------------------------------------------------
>
>                 Key: CALCITE-5563
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5563
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: asdfgh19
>            Assignee: asdfgh19
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.35.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
>  
> {code:java}
> /**
>  * Returns the collection of RelNodes one of whose inputs is in this
>  * subset.
>  */
> Set<RelNode> getParents() {
>   final Set<RelNode> list = new LinkedHashSet<>();
>   for (RelNode parent : set.getParentRels()) {
>     for (RelSubset rel : inputSubsets(parent)) {
>       // see usage of this method in propagateCostImprovements0()
>       if (rel == this) {
>         list.add(parent);
>         break;
>       }
>     }
>   }
>   return list;
> }
> /**
>  * Returns the collection of distinct subsets that contain a RelNode one
>  * of whose inputs is in this subset.
>  */
> Set<RelSubset> getParentSubsets(VolcanoPlanner planner) {
>   final Set<RelSubset> list = new LinkedHashSet<>();
>   for (RelNode parent : set.getParentRels()) {
>     for (RelSubset rel : inputSubsets(parent)) {
>       if (rel.set == set && rel.getTraitSet().equals(traitSet)) {
>         list.add(planner.getSubsetNonNull(parent));
>         break;
>       }
>     }
>   }
>   return list;
> }{code}
>  
> Once we have found a matching Relsubset from its parent input, the subsequent inner loop is unnecessary,so we can immediately end the inner loop to save a little time. This is just a minor improment.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)