This repository has been archived by the owner on Mar 9, 2019. It is now read-only.
forked from apache/drill
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRILL-166 Update CodeGenerator code to support more generic signatures.
- Loading branch information
Showing
51 changed files
with
1,302 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...exec/java-exec/src/main/java/org/apache/drill/exec/compile/sig/CodeGeneratorArgument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.apache.drill.exec.compile.sig; | ||
|
||
|
||
public class CodeGeneratorArgument { | ||
|
||
private final String name; | ||
private final Class<?> type; | ||
|
||
public CodeGeneratorArgument(String name, Class<?> type) { | ||
super(); | ||
this.name = name; | ||
this.type = type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Class<?> getType() { | ||
return type; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...e/exec/java-exec/src/main/java/org/apache/drill/exec/compile/sig/CodeGeneratorMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.apache.drill.exec.compile.sig; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.Iterators; | ||
import com.thoughtworks.paranamer.AnnotationParanamer; | ||
import com.thoughtworks.paranamer.Paranamer; | ||
|
||
public class CodeGeneratorMethod implements Iterable<CodeGeneratorArgument>{ | ||
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CodeGeneratorMethod.class); | ||
|
||
private final String methodName; | ||
private final Class<?> returnType; | ||
private final CodeGeneratorArgument[] arguments; | ||
private final Class<?>[] exs; | ||
private final Method underlyingMethod; | ||
|
||
public CodeGeneratorMethod(Method m){ | ||
this.underlyingMethod = m; | ||
this.methodName = m.getName(); | ||
this.returnType = m.getReturnType(); | ||
// Paranamer para = new BytecodeReadingParanamer(); | ||
Paranamer para = new AnnotationParanamer(); | ||
String[] parameterNames = para.lookupParameterNames(m, true); | ||
if(parameterNames == null) throw new RuntimeException(String.format("Unable to read the parameter names for method %s. This is likely due to the class files not including the appropriate debugging information. Look up java -g for more information.", m)); | ||
Class<?>[] types = m.getParameterTypes(); | ||
if(parameterNames.length != types.length) throw new RuntimeException(String.format("Unexpected number of parameter names %s. Expected %s on method %s.", Arrays.toString(parameterNames), Arrays.toString(types), m.toGenericString())); | ||
arguments = new CodeGeneratorArgument[parameterNames.length]; | ||
for(int i =0 ; i < parameterNames.length; i++){ | ||
arguments[i] = new CodeGeneratorArgument(parameterNames[i], types[i]); | ||
} | ||
exs = m.getExceptionTypes(); | ||
} | ||
|
||
public String getMethodName() { | ||
return methodName; | ||
} | ||
public Class<?> getReturnType() { | ||
return returnType; | ||
} | ||
|
||
public Iterable<Class<?>> getThrowsIterable(){ | ||
return ImmutableList.copyOf(exs); | ||
} | ||
|
||
@Override | ||
public Iterator<CodeGeneratorArgument> iterator() { | ||
return Iterators.forArray(arguments); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CodeGeneratorMethod [" + underlyingMethod.toGenericString() + "]"; | ||
} | ||
|
||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...xec/java-exec/src/main/java/org/apache/drill/exec/compile/sig/CodeGeneratorSignature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.apache.drill.exec.compile.sig; | ||
|
||
|
||
public interface CodeGeneratorSignature { | ||
} |
Oops, something went wrong.