[
https://issues.apache.org/jira/browse/CALCITE-5563?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
asdfgh19 updated CALCITE-5563:
------------------------------
Description:
{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.
was:
{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.
> Add a break to the inner loop of RelSubset#getParents and
> RelSubset#getParentSubsets after we find a matching Relsubset from its parent
> input
> ---------------------------------------------------------------------------------------------------------------------------------------------
>
> 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.34.0
>
> Time Spent: 20m
> 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)