diff options
author | Paul Rogers <progers@maprtech.com> | 2016-12-12 17:30:56 -0800 |
---|---|---|
committer | Jinfeng Ni <jni@apache.org> | 2017-01-10 16:40:32 -0800 |
commit | ee399317a1faa44e18aedcb11cfa5d4d5c0941aa (patch) | |
tree | d6123928c19349ae40c6d504a93ed9cd59cbd082 /exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter | |
parent | 4d4e0c2b23caead69dd4c6c02c07a9800b3c7611 (diff) |
DRILL-5116: Enable generated code debugging in each Drill operator
DRILL-5052 added the ability to debug generated code. The reviewer suggested
permitting the technique to be used for all Drill operators. This PR provides
the required fixes. Most were small changes, others dealt with the rather
clever way that the existing byte-code merge converted static nested classes
to non-static inner classes, with the way that constructors were inserted
at the byte-code level and so on. See the JIRA for the details.
This code passed the unit tests twice: once with the traditional byte-code
manipulations, a second time using "plain-old Java" code compilation.
Plain-old Java is turned off by default, but can be turned on for all
operators with a single config change: see the JIRA for info. Consider
the plain-old Java option to be experimental: very handy for debugging,
perhaps not quite tested enough for production use.
close apache/drill#716
Diffstat (limited to 'exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter')
3 files changed, 26 insertions, 13 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterRecordBatch.java index 4b161859e..6dfd3111b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterRecordBatch.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -77,7 +77,11 @@ public class FilterRecordBatch extends AbstractSingleRecordBatch<Filter>{ protected IterOutcome doWork() { container.zeroVectors(); int recordCount = incoming.getRecordCount(); - filter.filterBatch(recordCount); + try { + filter.filterBatch(recordCount); + } catch (SchemaChangeException e) { + throw new UnsupportedOperationException(e); + } return IterOutcome.OK; } @@ -191,7 +195,11 @@ public class FilterRecordBatch extends AbstractSingleRecordBatch<Filter>{ try { final TransferPair[] tx = transfers.toArray(new TransferPair[transfers.size()]); - final Filterer filter = context.getImplementationClass(cg); + CodeGenerator<Filterer> codeGen = cg.getCodeGenerator(); + codeGen.plainJavaCapable(true); + // Uncomment out this line to debug the generated code. +// cg.saveCodeForDebugging(true); + final Filterer filter = context.getImplementationClass(codeGen); filter.setup(context, incoming, this, tx); return filter; } catch (ClassTransformationException | IOException e) { diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterTemplate2.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterTemplate2.java index d3f9eda7e..d014a2efe 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterTemplate2.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/FilterTemplate2.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -36,7 +36,7 @@ public abstract class FilterTemplate2 implements Filterer{ private TransferPair[] transfers; @Override - public void setup(FragmentContext context, RecordBatch incoming, RecordBatch outgoing, TransferPair[] transfers) throws SchemaChangeException{ + public void setup(FragmentContext context, RecordBatch incoming, RecordBatch outgoing, TransferPair[] transfers) throws SchemaChangeException { this.transfers = transfers; this.outgoingSelectionVector = outgoing.getSelectionVector2(); this.svMode = incoming.getSchema().getSelectionVectorMode(); @@ -60,7 +60,8 @@ public abstract class FilterTemplate2 implements Filterer{ } } - public void filterBatch(int recordCount){ + @Override + public void filterBatch(int recordCount) throws SchemaChangeException{ if (recordCount == 0) { return; } @@ -80,7 +81,7 @@ public abstract class FilterTemplate2 implements Filterer{ doTransfers(); } - private void filterBatchSV2(int recordCount){ + private void filterBatchSV2(int recordCount) throws SchemaChangeException { int svIndex = 0; final int count = recordCount; for(int i = 0; i < count; i++){ @@ -93,7 +94,7 @@ public abstract class FilterTemplate2 implements Filterer{ outgoingSelectionVector.setRecordCount(svIndex); } - private void filterBatchNoSV(int recordCount){ + private void filterBatchNoSV(int recordCount) throws SchemaChangeException { int svIndex = 0; for(int i = 0; i < recordCount; i++){ if(doEval(i, 0)){ @@ -104,7 +105,12 @@ public abstract class FilterTemplate2 implements Filterer{ outgoingSelectionVector.setRecordCount(svIndex); } - public abstract void doSetup(@Named("context") FragmentContext context, @Named("incoming") RecordBatch incoming, @Named("outgoing") RecordBatch outgoing); - public abstract boolean doEval(@Named("inIndex") int inIndex, @Named("outIndex") int outIndex); + public abstract void doSetup(@Named("context") FragmentContext context, + @Named("incoming") RecordBatch incoming, + @Named("outgoing") RecordBatch outgoing) + throws SchemaChangeException; + public abstract boolean doEval(@Named("inIndex") int inIndex, + @Named("outIndex") int outIndex) + throws SchemaChangeException; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/Filterer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/Filterer.java index fd7a13f65..aa45f54ff 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/Filterer.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/filter/Filterer.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -27,9 +27,8 @@ public interface Filterer { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Filterer.class); public void setup(FragmentContext context, RecordBatch incoming, RecordBatch outgoing, TransferPair[] transfers) throws SchemaChangeException; - public void filterBatch(int recordCount); + public void filterBatch(int recordCount) throws SchemaChangeException; public static TemplateClassDefinition<Filterer> TEMPLATE_DEFINITION2 = new TemplateClassDefinition<Filterer>(Filterer.class, FilterTemplate2.class); public static TemplateClassDefinition<Filterer> TEMPLATE_DEFINITION4 = new TemplateClassDefinition<Filterer>(Filterer.class, FilterTemplate4.class); - } |