Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [15/15] git commit: DRILL-352: Extract ClassGenerator from CodeGenerator. Use hierarchal set of ClassGenerators to support implementation of an arbitrarily complex inner class hierarchy. Introduce @RuntimeOveridden annotation to allow overrides of inne


Copy link to this message
-
[15/15] git commit: DRILL-352: Extract ClassGenerator from CodeGenerator. Use hierarchal set of ClassGenerators to support implementation of an arbitrarily complex inner class hierarchy. Introduce @RuntimeOveridden annotation to allow overrides of inne
DRILL-352: Extract ClassGenerator from CodeGenerator.  Use hierarchal set of ClassGenerators to support implementation of an arbitrarily complex inner class hierarchy.  Introduce @RuntimeOveridden annotation to allow overrides of inner classes without requiring abstract inner classes.  Update operators to use methods.  Add test for inner class generation.  Remove support for JDK based compilation, focusing entirely on Janino based compilation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/36a7637f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/36a7637f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/36a7637f

Branch: refs/heads/master
Commit: 36a7637f29d8b569a75ff9090aff01235494c4ec
Parents: a0eabf6
Author: Jacques Nadeau <[EMAIL PROTECTED]>
Authored: Wed Jan 29 16:03:40 2014 -0800
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Thu Jan 30 10:46:07 2014 -0800

----------------------------------------------------------------------
 .../drill/exec/compile/ByteCodeLoader.java      |  60 +++
 .../drill/exec/compile/ClassBodyBuilder.java    |   9 -
 .../drill/exec/compile/ClassCompiler.java       |   2 +-
 .../drill/exec/compile/ClassTransformer.java    | 476 +++++++++----------
 .../drill/exec/compile/JDKClassCompiler.java    | 178 -------
 .../drill/exec/compile/JaninoClassCompiler.java |  11 +-
 .../apache/drill/exec/compile/MergeAdapter.java | 233 +++++++++
 .../drill/exec/compile/QueryClassLoader.java    |   6 +-
 .../exec/compile/TemplateClassDefinition.java   |  10 +-
 .../exec/compile/sig/GeneratorMapping.java      |   2 +-
 .../exec/compile/sig/RuntimeOverridden.java     |  31 ++
 .../drill/exec/compile/sig/SignatureHolder.java |  40 +-
 .../apache/drill/exec/expr/ClassGenerator.java  | 358 ++++++++++++++
 .../apache/drill/exec/expr/CodeGenerator.java   | 361 +++-----------
 .../drill/exec/expr/EvaluationVisitor.java      |  46 +-
 .../exec/expr/HoldingContainerExpression.java   |   2 +-
 .../drill/exec/expr/fn/DrillAggFuncHolder.java  |  12 +-
 .../drill/exec/expr/fn/DrillFuncHolder.java     |  18 +-
 .../exec/expr/fn/DrillSimpleFuncHolder.java     |  10 +-
 .../drill/exec/expr/fn/FunctionConverter.java   |  14 +-
 .../apache/drill/exec/ops/FragmentContext.java  |  11 +-
 .../exec/physical/impl/aggregate/AggBatch.java  |  19 +-
 .../physical/impl/filter/FilterRecordBatch.java |   6 +-
 .../exec/physical/impl/join/MergeJoinBatch.java |  11 +-
 .../impl/mergereceiver/MergingRecordBatch.java  |  49 +-
 .../OrderedPartitionRecordBatch.java            |  76 ++-
 .../PartitionSenderRootExec.java                |   7 +-
 .../impl/project/ProjectRecordBatch.java        |  10 +-
 .../exec/physical/impl/sort/SortBatch.java      |  22 +-
 .../impl/svremover/RemovingRecordBatch.java     |  11 +-
 .../apache/drill/exec/compile/ExampleInner.java |  23 +
 .../exec/compile/ExampleTemplateWithInner.java  |  50 ++
 .../exec/compile/TestClassCompilationTypes.java |   2 +-
 .../exec/compile/TestClassTransformation.java   |  55 ++-
 .../apache/drill/exec/expr/ExpressionTest.java  |   4 +-
 35 files changed, 1320 insertions(+), 915 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/36a7637f/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ByteCodeLoader.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ByteCodeLoader.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ByteCodeLoader.java
new file mode 100644
index 0000000..36db0ed
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/ByteCodeLoader.java
@@ -0,0 +1,60 @@
+/**
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.compile;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.drill.exec.exception.ClassTransformationException;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.io.Resources;
+
+class ByteCodeLoader {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ByteCodeLoader.class);
+  
+  
+  private final LoadingCache<String, byte[]> byteCode = CacheBuilder.newBuilder().maximumSize(10000)
+      .expireAfterWrite(10, TimeUnit.MINUTES).build(new ClassBytesCacheLoader());
+
+  private class ClassBytesCacheLoader extends CacheLoader<String, byte[]> {
+    public byte[] load(String path) throws ClassTransformationException, IOException {
+      URL u = this.getClass().getResource(path);
+      if (u == null)
+        throw new ClassTransformationException(String.format("Unable to find TemplateClass at path %s", path));
+      return Resources.toByteArray(u);
+    }
+  };
+
+  public byte[] getClassByteCodeFromPath(String path) throws ClassTransformationException, IOException {
+    try {
+      return byteCode.get(path);
+    } catch (Execut