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

Zoltan Haindrich commented on CALCITE-2883:
-------------------------------------------

I think it would probably make sense to add a program option to make it 
possible to control the instruction loop.

> HepPlanner subprogram may loop till getting out of memory
> ---------------------------------------------------------
>
>                 Key: CALCITE-2883
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2883
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jesus Camacho Rodriguez
>            Assignee: Jesus Camacho Rodriguez
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.19.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Consider the following two hep programs.
> Program 1:
> {code}
> final HepProgramBuilder programBuilder = new HepProgramBuilder();
> programBuilder.addMatchOrder(HepMatchOrder.BOTTOM_UP);
> programBuilder.addRuleInstance(JoinToMultiJoinRule.INSTANCE);
> programBuilder.addRuleInstance(LoptOptimizeJoinRule.INSTANCE);
> final HepProgram program = programBuilder.build();
> {code}
> Program 2:
> {code}
> final HepProgramBuilder programBuilder = new HepProgramBuilder();
> final HepProgramBuilder subprogramBuilder = new HepProgramBuilder();
> subprogramBuilder.addMatchOrder(HepMatchOrder.BOTTOM_UP);
> subprogramBuilder.addRuleInstance(JoinToMultiJoinRule.INSTANCE);
> subprogramBuilder.addRuleInstance(LoptOptimizeJoinRule.INSTANCE);
> programBuilder.addSubprogram(subprogramBuilder.build());
> final HepProgram program = programBuilder.build();
> {code}
> I would expect both programs to behave similarly. However, program 2 will 
> loop indefinitely. The reason is that {{HepPlanner}} subprogram execution 
> loops if subprogram generates any new expression.
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java#L339
> This does not seem right since planner can control exiting the program (and 
> thus, subprogram) depending on its own internal state and configuration 
> properties, e.g., match limit.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to