drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [04/17] git commit: DRILL-1153: Add $sum0 implementations
Date Tue, 29 Jul 2014 15:38:16 GMT
DRILL-1153: Add $sum0 implementations


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/0a603df3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/0a603df3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/0a603df3

Branch: refs/heads/master
Commit: 0a603df36f53cf7a8d6025745cafd3f30843b5be
Parents: 913fad8
Author: Jacques Nadeau <jacques@apache.org>
Authored: Sun Jul 27 14:45:10 2014 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Jul 27 14:45:10 2014 -0700

----------------------------------------------------------------------
 exec/java-exec/src/main/codegen/config.fmpp     |  1 +
 .../java-exec/src/main/codegen/data/SumZero.tdd | 31 +++++++
 .../src/main/codegen/templates/SumZeroAggr.java | 96 ++++++++++++++++++++
 3 files changed, 128 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0a603df3/exec/java-exec/src/main/codegen/config.fmpp
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/config.fmpp b/exec/java-exec/src/main/codegen/config.fmpp
index 72520f6..ff6135d 100644
--- a/exec/java-exec/src/main/codegen/config.fmpp
+++ b/exec/java-exec/src/main/codegen/config.fmpp
@@ -35,6 +35,7 @@ data: {
     dateIntervalFunc: tdd(../data/DateIntervalFunc.tdd),
     intervalNumericTypes: tdd(../data/IntervalNumericTypes.tdd),
     extract: tdd(../data/ExtractTypes.tdd),
+    sumzero: tdd(../data/SumZero.tdd),
     numericTypes: tdd(../data/NumericTypes.tdd)
 }
 freemarkerLinks: {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0a603df3/exec/java-exec/src/main/codegen/data/SumZero.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/SumZero.tdd b/exec/java-exec/src/main/codegen/data/SumZero.tdd
new file mode 100644
index 0000000..b270d92
--- /dev/null
+++ b/exec/java-exec/src/main/codegen/data/SumZero.tdd
@@ -0,0 +1,31 @@
+# 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.
+
+{
+types: [
+    {inputType: "Bit", outputType: "NullableBit", runningType: "Bit", major: "Numeric"},
+    {inputType: "Int", outputType: "NullableBigInt", runningType: "BigInt", major: "Numeric"},
+    {inputType: "BigInt", outputType: "NullableBigInt", runningType: "BigInt", major: "Numeric"},
+    {inputType: "NullableBit", outputType: "NullableBit", runningType: "Bit", major: "Numeric"},
+    {inputType: "NullableInt", outputType: "NullableBigInt", runningType: "BigInt", major:
"Numeric"},
+    {inputType: "NullableBigInt", outputType: "NullableBigInt", runningType: "BigInt", major:
"Numeric"},
+    {inputType: "Float4", outputType: "NullableFloat8", runningType: "Float8", major: "Numeric"},
+    {inputType: "Float8", outputType: "NullableFloat8", runningType: "Float8", major: "Numeric"},
+    {inputType: "NullableFloat4", outputType: "NullableFloat8", runningType: "Float8", major:
"Numeric"},
+    {inputType: "NullableFloat8", outputType: "NullableFloat8", runningType: "Float8", major:
"Numeric"}
+   ]
+}  
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/0a603df3/exec/java-exec/src/main/codegen/templates/SumZeroAggr.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/SumZeroAggr.java b/exec/java-exec/src/main/codegen/templates/SumZeroAggr.java
new file mode 100644
index 0000000..0eab23d
--- /dev/null
+++ b/exec/java-exec/src/main/codegen/templates/SumZeroAggr.java
@@ -0,0 +1,96 @@
+/**
+ * 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.
+ */
+<@pp.dropOutputFile />
+
+
+
+
+<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/gaggr/SumZeroFunctions.java"
/>
+
+<#include "/@includes/license.ftl" />
+
+/* 
+ * This class is automatically generated from SumZero.tdd using FreeMarker.
+ */
+
+package org.apache.drill.exec.expr.fn.impl.gaggr;
+
+import org.apache.drill.exec.expr.DrillAggFunc;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate;
+import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
+import org.apache.drill.exec.expr.annotations.Output;
+import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.annotations.Workspace;
+import org.apache.drill.exec.expr.holders.*;
+import org.apache.drill.exec.record.RecordBatch;
+
+@SuppressWarnings("unused")
+
+public class SumZeroFunctions {
+	static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SumZeroFunctions.class);
+
+	<#list sumzero.types as type>
+
+	@FunctionTemplate(name = "$sum0", scope = FunctionTemplate.FunctionScope.POINT_AGGREGATE)
+	public static class ${type.inputType}SumZero implements DrillAggFunc{
+
+  @Param ${type.inputType}Holder in;
+  @Workspace ${type.runningType}Holder value;
+  @Workspace BigIntHolder callCount;
+  @Output ${type.outputType}Holder out;
+  
+  
+  public void setup(RecordBatch b) {
+    value.value = 0;
+    callCount.value = 0;
+  }
+  
+  @Override
+  public void add() {
+    callCount.value++;
+    <#if type.inputType?starts_with("Nullable") >
+    if(in.isSet == 1){
+      value.value += in.value;
+    }
+    <#else>
+    value.value += in.value;
+    </#if>
+  }
+
+  @Override
+  public void output() {
+    if(callCount.value > 0){
+      out.value = value.value;
+      out.isSet = 1;
+    }else{
+      out.isSet = 0;
+    }
+    
+  }
+
+  @Override
+  public void reset() {
+	  value.value = 0;
+	  callCount.value = 0;
+  }
+ 
+ }
+
+</#list>
+}
+


Mime
View raw message