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

Paul Rogers commented on DRILL-5116:
------------------------------------

Much complexity surrounds nested classes. The byte-code fix-ups must be doing 
some real magic. Nested classes in only a few places such as hash aggregates:

{code}
public abstract class HashAggTemplate implements HashAggregator {
  ...
  public class BatchHolder {
  ... }
  private void addBatchHolder() {
    BatchHolder bh = new BatchHolder();
    ...
{code}

Somehow, when the byte code transforms are done, the "new" above of the 
template's nested class is replaced with a "new" of the generated subclass of 
the nested class. Plain old Java can't do this trick. Instead, we need to 
insert a "shim" method:

{code}
  private void addBatchHolder() {
    BatchHolder bh = newBatchHolder();
    ... }
  protected BatchHolder newBatchHolder() {
    return new BatchHolder();
  }
{code}

Then, the generated code must override the shim to create an instance of the 
generated nested class:

{code}
    protected HashAggTemplate.BatchHolder newBatchHolder() {
        return new HashAggregatorGen29 .BatchHolder();
    }
{code}

> Enable generated code debugging in each Drill operator
> ------------------------------------------------------
>
>                 Key: DRILL-5116
>                 URL: https://issues.apache.org/jira/browse/DRILL-5116
>             Project: Apache Drill
>          Issue Type: Improvement
>    Affects Versions: 1.9.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>
> DRILL-5052 adds the ability to debug generated code. Some of the code 
> generated by Drill's operators has minor problems when compiled directly 
> using the new technique. These issues are ignore by the byte-code-merge 
> technique uses in production. This ticket asks to try the DRILL-5052 feature 
> in each operator, clean up any minor problems, and ensure each operator 
> generates code suitable for debugging. Use the new 
> {{CodeGenerator.plainOldJavaCapable()}} method to mark each generated class 
> as ready for "plain-old Java" code gen.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to