[
https://issues.apache.org/jira/browse/DRILL-346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jinfeng Ni updated DRILL-346:
-----------------------------
Attachment: genAdd_constant_master.java
genAdd_constant_Drill-346.java
I attached two generated classes, for expression : 1 + 2.
The first one is generated with Drill-346 code. The second one is generated w/o
Drill-346 code. The difference between the two generated classes is the
evaluation code for 1+2 is put in doSetup() method after Drill-346 code is
applied, so that it is executed only once per record batch, in stead of per
record value, hence improve query execution performance.
> Runtime generated code should evaluate constant expression once in doSetup
> method
> ---------------------------------------------------------------------------------
>
> Key: DRILL-346
> URL: https://issues.apache.org/jira/browse/DRILL-346
> Project: Apache Drill
> Issue Type: Bug
> Reporter: Jinfeng Ni
> Assignee: Jinfeng Ni
> Attachments: DRILL_346.2.patch.txt, genAdd_constant_Drill-346.java,
> genAdd_constant_master.java
>
>
> Currently, when runtime CodeGenerator logic generates class to evaluate an
> expression, it would put the code in doEval() method, regardless of whether
> the expression is a constant, or part of the expression is a constant. This
> means the generated code for the constant expression will be executed once
> for every record, in stead of once for each record batch.
> For a constant expression, we should put the code in doSetup() method, so
> that it will be executed once per record batch. Doing so would improve
> runtime code efficiency.
> In addition, for some function call expression, if the arguments are
> constant, we may want to refer to the constant arguments in doSetup(). For
> instance, given function : regexp_replae(input_string, regex, replace), if
> regex is a constant (eg : regexp_replace(varcharcol, "a[bc]", "XYZ") ), the
> implementation of regexp_replace would use the constant to build a
> java.Pattern in doSetup(), and repeatedly use that java.Pattern object in
> doEval() for each record. This requires CodeGenerator to make the constant
> arguments accessible to doSetup() method for function call.
>
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)