You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ol...@apache.org on 2008/10/30 22:27:17 UTC
svn commit: r709249 [1/4] - in /hadoop/pig/branches/types/contrib: ./
piggybank/ piggybank/java/ piggybank/java/lib/ piggybank/java/src/
piggybank/java/src/main/ piggybank/java/src/main/java/
piggybank/java/src/main/java/org/ piggybank/java/src/main/ja...
Author: olga
Date: Thu Oct 30 14:27:14 2008
New Revision: 709249
URL: http://svn.apache.org/viewvc?rev=709249&view=rev
Log:
Integration of piggybank
Added:
hadoop/pig/branches/types/contrib/
hadoop/pig/branches/types/contrib/CHANGES.txt
hadoop/pig/branches/types/contrib/piggybank/
hadoop/pig/branches/types/contrib/piggybank/java/
hadoop/pig/branches/types/contrib/piggybank/java/build.xml (with props)
hadoop/pig/branches/types/contrib/piggybank/java/lib/
hadoop/pig/branches/types/contrib/piggybank/java/src/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/comparison/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ABS.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ACOS.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ASIN.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN2.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Base.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CBRT.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CEIL.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COS.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COSH.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleAbs.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleBase.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleCopySign.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleDoubleBase.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleGetExponent.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMax.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMin.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextAfter.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextup.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleRound.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleSignum.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleUlp.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXP.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXPM1.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FLOOR.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatAbs.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatCopySign.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatGetExponent.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMax.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMin.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextAfter.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextup.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatRound.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatSignum.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatUlp.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/HYPOT.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IEEEremainder.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntAbs.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMax.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMin.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG10.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG1P.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongAbs.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMax.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMin.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MAX.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MIN.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/NEXTUP.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/POW.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RANDOM.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RINT.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ROUND.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/SCALB.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/SIGNUM.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/SIN.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/SINH.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/SQRT.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/TAN.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/TANH.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ULP.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Util.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/copySign.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/getExponent.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/nextAfter.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/toDegrees.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/toRadians.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/stats/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/stats/COR.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/stats/COV.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/string/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/string/UPPER.java
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/util/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/filtering/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/grouping/
hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/storage/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/comparison/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/TestEvalString.java
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/TestMathUDF.java
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/TestStat.java
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/filtering/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/grouping/
hadoop/pig/branches/types/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/
Added: hadoop/pig/branches/types/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/CHANGES.txt?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/CHANGES.txt (added)
+++ hadoop/pig/branches/types/contrib/CHANGES.txt Thu Oct 30 14:27:14 2008
@@ -0,0 +1,3 @@
+PIG-246: created UDF repository (olgan)
+PIG-245: UDF wrappers for Java Math functions (ajaygarg via olgan)
+PIG-277: UDF for computing correlation and covariance between data sets (ajaygarg via olgan)
Added: hadoop/pig/branches/types/contrib/piggybank/java/build.xml
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/build.xml?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/build.xml (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/build.xml Thu Oct 30 14:27:14 2008
@@ -0,0 +1,122 @@
+<!--
+ 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.
+-->
+
+<project basedir="." default="jar" name="pigudf">
+ <!-- javac properties -->
+ <property name="javac.debug" value="on" />
+ <property name="javac.level" value="source,lines,vars"/>
+ <property name="javac.optimize" value="on" />
+ <property name="javac.deprecation" value="off" />
+ <property name="javac.version" value="1.5" />
+ <property name="javac.args" value="" />
+ <!-- TODO we should use warning... <property name="javac.args.warnings" value="-Xlint:unchecked" /> -->
+ <property name="javac.args.warnings" value="" />
+
+ <!-- build properties -->
+ <property name="build.dir" value="${basedir}/build" />
+ <property name="build.classes" value="${build.dir}/classes" />
+ <property name="build.docs" value="${build.dir}/docs" />
+ <property name="build.javadoc" value="${build.docs}/api" />
+ <property name="pigjar" value="../../../pig.jar" />
+ <property name="udfjar" value="piggybank.jar" />
+ <property name="src.dir" value="src/main/java/org/apache/pig/piggybank" />
+
+ <!-- jar properties -->
+ <property name=".javadoc" value="${build.docs}/api" />
+
+ <!-- test properties -->
+ <property name="test.build.dir" value="${build.dir}/test" />
+ <property name="test.classes" value="${test.build.dir}/classes" />
+ <property name="test.logs" value="${test.build.dir}/logs" />
+ <property name="test.timeout" value="900000" />
+ <property name="test.junit.output.format" value="plain" />
+ <property name="test.src.dir" value="src/test/java" />
+
+ <path id="pigudf.classpath">
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${pigjar}"/>
+ </path>
+
+ <path id="test.classpath">
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${test.classes}"/>
+ <pathelement location="${test.src.dir}"/>
+ <path refid="pigudf.classpath"/>
+ </path>
+
+ <target name="init">
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.classes}"/>
+ <mkdir dir="${test.build.dir}"/>
+ <mkdir dir="${test.classes}"/>
+ <mkdir dir="${build.javadoc}"/>
+ </target>
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+ <target depends="init" name="compile" description="compile all of the class files">
+ <echo> *** Compiling Pig UDFs ***</echo>
+ <javac srcdir="${src.dir}" debug="${javac.debug}" debuglevel="${javac.level}" destdir="${build.classes}" source="${javac.version}"
+ target="${javac.version}" optimize="${javac.optimize}" deprecation="${javac.deprecation}">
+ <compilerarg line="${javac.args} ${javac.args.warnings}" />
+ <classpath refid="pigudf.classpath"/>
+ </javac>
+ </target>
+ <target depends="init,compile" name="jar" description="create the jar files">
+ <echo> *** Creating pigudf.jar ***</echo>
+ <jar destfile="${udfjar}">
+ <fileset dir="build/classes"/>
+ </jar>
+ </target>
+ <target depends="compile" name="compile-test">
+ <echo> *** Compiling UDF tests ***</echo>
+ <javac srcdir="${test.src.dir}" debug="true" debuglevel="${debuglevel}" destdir="${test.classes}" source="${javac.version}" target="${javac.version}">
+ <classpath refid="pigudf.classpath"/>
+ </javac>
+ </target>
+ <target depends="compile-test,jar" name="test">
+ <echo> *** Running UDF tests ***</echo>
+ <delete dir="${test.logs}"/>
+ <mkdir dir="${test.logs}"/>
+ <junit printsummary="yes" haltonfailure="no" fork="yes" maxmemory="256m" dir="${basedir}" timeout="${test.timeout}" errorProperty="tests.failed" failureProperty="tests.failed">
+ <classpath refid="test.classpath"/>
+ <formatter type="${test.junit.output.format}" />
+ <batchtest fork="yes" todir="${test.logs}" unless="testcase">
+ <fileset dir="${test.src.dir}">
+ <include name="**/*Test*.java" />
+ </fileset>
+ </batchtest>
+ <batchtest fork="yes" todir="${test.logs}" if="testcase">
+ <fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
+ </batchtest>
+ </junit>
+ <fail if="tests.failed">Tests failed!</fail>
+ </target>
+ <target depends="init" name="javadoc"
+ description="build javadoc for all of the packages">
+ <echo> *** Creating Javadocs ***</echo>
+ <javadoc destdir="build/javadoc"
+ author="true">
+ <fileset dir="${src.dir}/evaluation" includes="**/*.java"/>
+ <fileset dir="${src.dir}/storage" includes="**/*.java"/>
+ <fileset dir="${src.dir}/filtering" includes="**/*.java"/>
+ <fileset dir="${src.dir}/grouping" includes="**/*.java"/>
+ <fileset dir="${src.dir}/comparison" includes="**/*.java"/>
+ <classpath refid="pigudf.classpath"/>
+ </javadoc>
+ </target>
+</project>
Propchange: hadoop/pig/branches/types/contrib/piggybank/java/build.xml
------------------------------------------------------------------------------
svn:executable = *
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ABS.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ABS.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ABS.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ABS.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,103 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.FuncSpec;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.impl.util.WrappedIOException;
+/**
+ * math.ABS implements a binding to the Java function
+ * {@link java.lang.Math#abs(double) Math.abs(double)} for computing the
+ * absolute value of the argument. The returned value will be a double which is
+ * absolute value of the input.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>numeric</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>numeric</code> absolute value of input</dd>
+ *
+ * <dt><b>Return Schema:</b></dt>
+ * <dd>abs_inputSchema</dd>
+ *
+ * <dt><b>Example:</b></dt>
+ * <dd><code>
+ * register math.jar;<br/>
+ * A = load 'mydata' using PigStorage() as ( float1 );<br/>
+ * B = foreach A generate float1, math.ABS(float1);
+ * </code></dd>
+ * </dl>
+ *
+ * @see Math#abs(double)
+ * @see
+ * @author ajay garg
+ *
+ */
+public class ABS extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, absolute value of the argument
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ Double d;
+ try{
+ d = DataType.toDouble(input.get(0));
+ } catch (NumberFormatException nfe){
+ System.err.println("Failed to process input; error - " + nfe.getMessage());
+ return null;
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+
+ return Math.abs(d);
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
+ */
+ @Override
+ public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
+ List<FuncSpec> funcList = new ArrayList<FuncSpec>();
+ funcList.add(new FuncSpec(this.getClass().getName(), new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY))));
+ funcList.add(new FuncSpec(DoubleAbs.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.DOUBLE))));
+ funcList.add(new FuncSpec(FloatAbs.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.FLOAT))));
+ funcList.add(new FuncSpec(IntAbs.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.INTEGER))));
+ funcList.add(new FuncSpec(LongAbs.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.LONG))));
+ return funcList;
+ }
+
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ACOS.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ACOS.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ACOS.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ACOS.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,56 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.ACOS implements a binding to the Java function
+* {@link java.lang.Math#acos(double) Math.acos(double)} for computing the
+* arc cosine of value of the argument. The returned value will be a double which is
+* the arc cosine of the value of input.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> arc cosine of the value of input</dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>acos_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ACOS(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#acos(double)
+* @see
+* @author ajay garg
+*
+*/
+public class ACOS extends DoubleBase{
+
+ Double compute(Double input){
+ return Math.acos(input);
+
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ASIN.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ASIN.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ASIN.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ASIN.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.ASIN implements a binding to the Java function
+* {@link java.lang.Math#asin(double) Math.asin(double)} for computing the
+* arc sine of value of the argument. The returned value will be a double which is
+* the arc sine of the value of input.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> arc sine of the value of input</dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>asin_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ASIN(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#asin(double)
+* @see
+* @author ajay garg
+*
+*/
+public class ASIN extends DoubleBase{
+ Double compute(Double input){
+ return Math.asin(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.ATAN implements a binding to the Java function
+* {@link java.lang.Math#atan(double) Math.atan(double)} for computing the
+* arc tangent of value of the argument. The returned value will be a double which is
+* the arc tangent of the value of input.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> arc tangent of the value of input</dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>atan_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ATAN(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#atan(double)
+* @see
+* @author ajay garg
+*
+*/
+public class ATAN extends DoubleBase{
+ Double compute(Double input){
+ return Math.atan(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN2.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN2.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN2.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/ATAN2.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.ATAN2 implements a binding to the Java function
+* {@link java.lang.Math#atan2(double,double) Math.atan2(double,double)}. Given a tuple with
+* two data atom x and y it will returns the angle theta from the conversion of
+* rectangular coordinates (x, y) to polar coordinates (r, theta).
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Tuple containing two Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>atan2_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ATAN2(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#atan2(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class ATAN2 extends DoubleDoubleBase{
+ Double compute(Double input1, Double input2){
+ return Math.atan2(input1, input2);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Base.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Base.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Base.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/Base.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+/**
+* base class for math udfs
+*/
+public abstract class Base extends EvalFunc<Double>{
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CBRT.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CBRT.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CBRT.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CBRT.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.CBRT implements a binding to the Java function
+* {@link java.lang.Math#cbrt(double) Math.cbrt(double)} for computing the
+ * cube root of the argument. The returned value will be a double which is
+ * cube root value of the input.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>cbrt_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.cbrt(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#cbrt(double)
+* @see
+* @author ajay garg
+*
+*/
+public class CBRT extends DoubleBase{
+ Double compute(Double input){
+ return Math.cbrt(input);
+
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CEIL.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CEIL.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CEIL.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/CEIL.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.CEIL implements a binding to the Java function
+* {@link java.lang.Math#ceil(double) Math.ceil(double)}. Given a single
+* data atom it Returns the smallest (closest to negative infinity)
+* double value that is greater than or equal to the argument and is equal
+* to a mathematical integer.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>ceil_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ceil(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#ceil(double)
+* @see
+* @author ajay garg
+*
+*/
+public class CEIL extends DoubleBase{
+ Double compute(Double input){
+ return Math.ceil(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COS.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COS.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COS.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COS.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.COS implements a binding to the Java function
+* {@link java.lang.Math#cos(double) Math.cos(double)}. Given a single
+* data atom it Returns the cosine value of the input
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>cos_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.cos(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#cos(double)
+* @see
+* @author ajay garg
+*
+*/
+public class COS extends DoubleBase{
+ Double compute(Double input){
+ return Math.cos(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COSH.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COSH.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COSH.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/COSH.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.COSH implements a binding to the Java function
+* {@link java.lang.Math#cosh(double) Math.cosh(double)}. Given a single
+* data atom it Returns the hyperbolic cosine value of the input
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>cosh_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.cosh(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#cosh(double)
+* @see
+* @author ajay garg
+*
+*/
+public class COSH extends DoubleBase{
+ Double compute(Double input){
+ return Math.cosh(input);
+
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleAbs.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleAbs.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleAbs.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleAbs.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.ABS implements a binding to the Java function
+ * {@link java.lang.Math#abs(double) Math.abs(double)} for computing the
+ * absolute value of the argument. The returned value will be an double which is
+ * absolute value of the input.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>double</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>double</code> absolute value of input</dd>
+ *
+ * <dt><b>Return Schema:</b></dt>
+ * <dd>abs_inputSchema</dd>
+ *
+ * <dt><b>Example:</b></dt>
+ * <dd><code>
+ * register math.jar;<br/>
+ * A = load 'mydata' using PigStorage() as ( float1 );<br/>
+ * B = foreach A generate float1, math.ABS(float1);
+ * </code></dd>
+ * </dl>
+ *
+ * @see Math#abs(double)
+ * @see
+ * @author ajay garg
+ *
+ */
+public class DoubleAbs extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, absolute value of the argument
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ Double d;
+ try{
+ d = (Double)input.get(0);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+
+ return Math.abs(d);
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleBase.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleBase.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleBase.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleBase.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,67 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.FuncSpec;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.util.WrappedIOException;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+
+/**
+* base class for math udfs that return Double value
+*/
+public abstract class DoubleBase extends Base{
+ // each derived class provides the computation here
+ abstract Double compute(Double input);
+
+ /**
+ * java level API
+ * @param input expects a tuple with a single Double value
+ * @param output returns a Double value
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try {
+ Double val = (Double)input.get(0);
+ return (val == null ? null : compute(val));
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input of " + this.getClass().getName(), e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
+ */
+ @Override
+ public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
+ List<FuncSpec> funcList = new ArrayList<FuncSpec>();
+ funcList.add(new FuncSpec(this.getClass().getName(), new Schema(new Schema.FieldSchema(null, DataType.DOUBLE))));
+
+ return funcList;
+ }
+
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleCopySign.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleCopySign.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleCopySign.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleCopySign.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,84 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.copySign implements a binding to the Java function
+* {@link java.lang.Math#copySign(double,double) Math.copySign(double,double)}.
+* Given a tuple with two data atom Returns the first floating-point argument
+* with the sign of the second floating-point argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Tuple containing two double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>copySign_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.copySign(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#copySign(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleCopySign extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a tuple containing two numeric DataAtom value
+ * @param output returns a single numeric DataAtom value, which is
+ * first floating-point argument with the sign of the second
+ * floating-point argument.
+ */
+ @Override
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() < 2)
+ return null;
+ try{
+ double first = (Double)input.get(0);
+ double second = (Double)input.get(1);
+ return Math.copySign(first, second);
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleDoubleBase.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleDoubleBase.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleDoubleBase.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleDoubleBase.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.FuncSpec;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.util.WrappedIOException;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+
+/**
+* base class for math udfs that return Double value
+*/
+public abstract class DoubleDoubleBase extends Base{
+ // each derived class provides the computation here
+ abstract Double compute(Double input1, Double input2);
+
+ /**
+ * java level API
+ * @param input expects a tuple with a single Double value
+ * @param output returns a Double value
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() < 2)
+ return null;
+
+ try {
+ Double val1 = (Double)input.get(0);
+ Double val2 = (Double)input.get(1);
+ return (val1 == null || val2 == null) ? null : compute(val1, val2);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input of " + this.getClass().getName(), e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.pig.EvalFunc#getArgToFuncMapping()
+ */
+ @Override
+ public List<FuncSpec> getArgToFuncMapping() throws FrontendException {
+ List<FuncSpec> funcList = new ArrayList<FuncSpec>();
+ List<Schema.FieldSchema> fields = new ArrayList<Schema.FieldSchema>();
+ fields.add(new Schema.FieldSchema(null, DataType.DOUBLE));
+ fields.add(new Schema.FieldSchema(null, DataType.DOUBLE));
+ funcList.add(new FuncSpec(this.getClass().getName(), new Schema(fields)));
+
+ return funcList;
+ }
+
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleGetExponent.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleGetExponent.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleGetExponent.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleGetExponent.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.getExponent implements a binding to the Java function
+* {@link java.lang.Math#getExponent(double) Math.getExponent(double)}.
+* Given a single data atom it returns the unbiased exponent used in
+* the representation of a double
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>int</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>getExponent_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.getExponent(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#getExponent(double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleGetExponent extends EvalFunc<Integer>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, unbiased
+ * exponent used in the representation of a double
+ */
+ public Integer exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try {
+ Double d = (Double)input.get(0);
+ return Math.getExponent(d);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.INTEGER));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMax.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMax.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMax.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMax.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.impl.util.WrappedIOException;
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+/**
+ * math.max implements a binding to the Java function
+ * {@link java.lang.Math#max(int,int) Math.max(int,int)} for computing the
+ * the max value of the arguments. The returned value will be an int which is
+ * the maximum of the inputs.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>2 int values</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>int</code> max value of two input</dd>
+ *
+ * <dt><b>Return Schema:</b></dt>
+ * <dd>max_inputSchema</dd>
+ *
+ * <dt><b>Example:</b></dt>
+ * <dd><code>
+ * register math.jar;<br/>
+ * A = load 'mydata' using PigStorage() as ( float1 );<br/>
+ * B = foreach A generate float1, math.max(float1);
+ * </code></dd>
+ * </dl>
+ *
+ * @see Math#max(double)
+ * @see
+ * @author ajay garg
+ *
+ */
+public class DoubleMax extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a two numeric value
+ * @param output returns a single numeric value, which is the smaller of two inputs
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Double first = (Double)input.get(0);
+ Double second = (Double)input.get(1);
+ return Math.max(first, second);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMin.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMin.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleMin.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.impl.util.WrappedIOException;
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+/**
+ * math.min implements a binding to the Java function
+ * {@link java.lang.Math#min(int,int) Math.min(int,int)} for computing the
+ * the min value of the arguments. The returned value will be an int which is
+ * the minimum of the inputs.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>2 int values</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>int</code> min value of two input</dd>
+ *
+ * <dt><b>Return Schema:</b></dt>
+ * <dd>min_inputSchema</dd>
+ *
+ * <dt><b>Example:</b></dt>
+ * <dd><code>
+ * register math.jar;<br/>
+ * A = load 'mydata' using PigStorage() as ( float1 );<br/>
+ * B = foreach A generate float1, math.min(float1);
+ * </code></dd>
+ * </dl>
+ *
+ * @see Math#min(double)
+ * @see
+ * @author ajay garg
+ *
+ */
+public class DoubleMin extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a two numeric value
+ * @param output returns a single numeric value, which is the smaller of two inputs
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Double first = (Double)input.get(0);
+ Double second = (Double)input.get(1);
+ return Math.min(first, second);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextAfter.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextAfter.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextAfter.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextAfter.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.FuncSpec;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.nextAfter implements a binding to the Java function
+* {@link java.lang.Math#nextAfter(double,double) Math.nextAfter(double,double)}.
+* Given a tuple with two data atom it Returns the
+* floating-point number adjacent to the first argument in the
+* direction of the second argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Tuple containing two double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>nextAfter_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.nextAfter(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#nextAfter(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleNextAfter extends EvalFunc<Double>{
+
+ /**
+ * java level API
+ * @param input expects a tuple containing two numeric DataAtom value
+ * @param output returns a single numeric DataAtom value, which is
+ * the floating-point number adjacent to the first argument in the
+ * direction of the second argument.
+ */
+ @Override
+ public Double exec(Tuple input) throws IOException {
+ try{
+ double first = (Double)input.get(0);
+ double second = (Double)input.get(0);
+ return Math.nextAfter(first, second);
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception in DoubleNextAfter", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextup.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextup.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextup.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleNextup.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.NEXTUP implements a binding to the Java function
+* {@link java.lang.Math#nextUp(double) Math.nextUp(double)}.
+* Given a single data atom it return the floating-point value
+* adjacent to input in the direction of positive infinity
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>NEXTUP_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.NEXTUP(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#nextUp(double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleNextup extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, nextup value of the argument
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+ Double d;
+ try{
+ d = (Double)input.get(0);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+
+ return Math.nextUp(d);
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleRound.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleRound.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleRound.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleRound.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.ROUND implements a binding to the Java function
+* {@link java.lang.Math#round(double) Math.round(double)}.
+* Given a single data atom it Returns the closest long to the argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Long</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>ROUND_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ROUND(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#round(double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleRound extends EvalFunc<Long>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value,
+ * the closest long to the argument
+ */
+ @Override
+ public Long exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Double d = (Double)input.get(0);
+ return Math.round(d);
+ } catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.LONG));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleSignum.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleSignum.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleSignum.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleSignum.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.SIGNUM implements a binding to the Java function
+* {@link java.lang.Math#signum(double) Math.signum(double)}.
+* Given a single data atom it Returns the signum function of the argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>SIGNUM_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.SIGNUM(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#signum(double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleSignum extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a single numeric DataAtom value
+ * @param output returns a single numeric DataAtom value,
+ * signum function of the argument
+ */
+ @Override
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Double d = (Double)input.get(0);
+ return Math.signum(d);
+ }catch (Exception e){
+ throw WrappedIOException.wrap("Caught exception processing input row ", e);
+ }
+
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleUlp.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleUlp.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleUlp.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/DoubleUlp.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.FuncSpec;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.data.DataType;
+import org.apache.pig.impl.logicalLayer.FrontendException;
+import org.apache.pig.impl.util.WrappedIOException;
+
+/**
+ * math.ULP implements a binding to the Java function
+* {@link java.lang.Math#ulp(double) Math.ulp(double)}.
+* Given a single data atom it Returns the size of an ulp
+* of the argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>ULP_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.ULP(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#ulp(double)
+* @see
+* @author ajay garg
+*
+*/
+public class DoubleUlp extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value,
+ * the size of an ulp of the argument.
+ */
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Double d = (Double)input.get(0);
+ return Math.ulp(d);
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception in DoubleUlp", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXP.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXP.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXP.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXP.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.pig.piggybank.evaluation.math;
+
+/**
+ * math.EXP implements a binding to the Java function
+* {@link java.lang.Math#exp(double) Math.exp(double)}. Given a single
+* data atom it Returns the Euler's number e raised to the power of input
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>exp_inputSchema</dd>
+*
+* <dt><b>Example:</b></dt>
+* <dd><code>
+* register math.jar;<br/>
+* A = load 'mydata' using PigStorage() as ( float1 );<br/>
+* B = foreach A generate float1, math.exp(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#exp(double)
+* @see
+* @author ajay garg
+*
+*/
+public class EXP extends DoubleBase {
+ Double compute(Double input){
+ return Math.exp(input);
+ }
+}