[ 
https://issues.apache.org/jira/browse/CALCITE-6109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17785339#comment-17785339
 ] 

Julian Hyde commented on CALCITE-6109:
--------------------------------------

Is the code block from the Calcite code? If so please indicate where. People 
need to be able to understand this bug with zero context.

What is the harm caused by this bug? Is it just a performance issue? Or is it 
possible to create a test case that - say - runs out of memory if the issue 
hasn't been fixed? Such test cases are preferable, because they are (almost) 
fool-proof.

In your summary, can you state plainly what is the problem.

> Avoid extra loops when optimizing statements with ternary expressions
> ---------------------------------------------------------------------
>
>                 Key: CALCITE-6109
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6109
>             Project: Calcite
>          Issue Type: Improvement
>          Components: linq4j
>            Reporter: asdfgh19
>            Assignee: asdfgh19
>            Priority: Minor
>              Labels: pull-request-available
>
> {code:java}
> public BlockStatement toBlock() {
>   if (optimizing && removeUnused) {
>     // We put an artificial limit of 10 iterations just to prevent an endless
>     // loop. Optimize should not loop forever, however it is hard to prove if
>     // it always finishes in reasonable time.
>     for (int i = 0; i < 10; i++) {
>       if (!optimize(createOptimizeShuttle(), true)) {
>         break;
>       }
>     }
>     optimize(createFinishingOptimizeShuttle(), false);
>   }
>   return Expressions.block(statements);
> } {code}
> When there are statements with ternary expressions in 
> BlockBuilder#statements, the optimize method always returns true, causing the 
> loop in the toBlock method to always be executed 10 times.
> The reason is that when OptimizeShuttle traverses the statement, a new 
> instance of TernaryExpression will always be created, regardless of whether 
> the optimization is actually performed.
>  



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

Reply via email to