[CALCITE-5703] Reduce amount of generated runtime code#3203
[CALCITE-5703] Reduce amount of generated runtime code#3203DonnyZone merged 1 commit intoapache:mainfrom
Conversation
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
Outdated
Show resolved
Hide resolved
|
A nice finding to reduce the generated code. From my perspective, the changes in |
|
A more suitable place to conduct such optimizations is Linq4J Optimizer. The similar test cases FYI:( ) |
|
@DonnyZone @rubenada new approach is force pushed, plz take a look? |
There was a problem hiding this comment.
The accept function is responsible for generating code string with ExpressionWriter. Instead of rewriting the fields in BinaryExpression and TernaryExpression, we can rewrite in the accept function to narrow the code change.
But the most appropriate place is the OptimizeShuttle, which is specific to optimizes expressions. You can add this case in it.
https://github.com/apache/calcite/blob/main/linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java
linq4j/src/test/java/org/apache/calcite/linq4j/test/OptimizerTest.java
Outdated
Show resolved
Hide resolved
|
As mentioned in jira |
|
@DonnyZone 3rd reincarnation ) is ready for review, @snuyanzin if i understand also if PR will be accepted we can`t merge it, do i need to fill the issue for bumping janino version in calcite or you can do it yourself ? |
|
I remember a discussion about that and it was a desicion to not create jira issues just for version updates... |
|
@DonnyZone thanks for review, but i still not hear any contradictions against this PR can be merged. If it so - is it possible to merge it ? |
Sorry for the late reply. I make some tests in my local environment. The optimization for While the code below works well. |
@DonnyZone thanks for reply I can`t obtain such a code after optimization ( can you show me how can i make it ? final ParameterExpression x_ = Expressions.parameter(Object.class, "x"); assertEquals("{\n public Object x = true;\n}\n", after optimization shows: |
I just pick the code from your UT. By the way, is it necessary to apply |
|
@DonnyZone got it, i refactor a code according to your suggestions and change the tests. |
linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java
Outdated
Show resolved
Hide resolved
linq4j/src/main/java/org/apache/calcite/linq4j/tree/OptimizeShuttle.java
Outdated
Show resolved
Hide resolved
|
Thanks for the work. Please address the final comment and squash the commits. I will merge it. |
|
Kudos, SonarCloud Quality Gate passed! |
|
@DonnyZone thanks for suggestions, all done. |








No description provided.