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 [2/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...
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXPM1.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXPM1.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXPM1.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/EXPM1.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.EXPM1 implements a binding to the Java function
+* {@link java.lang.Math#expm1(double) Math.expm1(double)}. Given a single
+* data atom it returns exp(input)+1
+*
+* <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>expm1_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.expm1(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#expm1(double)
+* @see
+* @author ajay garg
+*
+*/
+public class EXPM1 extends DoubleBase{
+ Double compute(Double input){
+ return Math.expm1(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FLOOR.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FLOOR.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FLOOR.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FLOOR.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.FLOOR implements a binding to the Java function
+* {@link java.lang.Math#floor(double) Math.floor(double)}. Given a single
+* data atom it returns the largest (closest to positive infinity) double
+* value that is less 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>floor_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.floor(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#floor(double)
+* @see
+* @author ajay garg
+*
+*/
+public class FLOOR extends DoubleBase{
+ Double compute(Double input){
+ return Math.floor(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatAbs.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatAbs.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatAbs.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatAbs.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.ABS implements a binding to the Java function
+ * {@link java.lang.Math#abs(double) Math.abs(float)} for computing the
+ * absolute value of the argument. The returned value will be an float which is
+ * absolute value of the input.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>float</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>float</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 FloatAbs extends EvalFunc<Float>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, absolute value of the argument
+ */
+ public Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ Float d;
+ try{
+ d = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatCopySign.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatCopySign.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatCopySign.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatCopySign.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(float,float) Math.copySign(float,float)}.
+* 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 float</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>float</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(float,float)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatCopySign extends EvalFunc<Float>{
+ /**
+ * 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 Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() < 2)
+ return null;
+ try{
+ float first = (Float)input.get(0);
+ float second = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatGetExponent.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatGetExponent.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatGetExponent.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatGetExponent.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>float</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 FloatGetExponent 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 {
+ Float d = (Float)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/FloatMax.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMax.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMax.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMax.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 FloatMax extends EvalFunc<Float>{
+ /**
+ * 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 Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Float first = (Float)input.get(0);
+ Float second = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMin.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMin.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatMin.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 FloatMin extends EvalFunc<Float>{
+ /**
+ * 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 Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Float first = (Float)input.get(0);
+ Float second = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextAfter.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextAfter.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextAfter.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextAfter.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 float and double</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>float</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(float,double)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatNextAfter extends EvalFunc<Float>{
+
+ /**
+ * 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 Float exec(Tuple input) throws IOException {
+ try{
+ Float first = (Float)input.get(0);
+ Double second = (Double)input.get(0);
+ return Math.nextAfter(first, second);
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception in FloatNextAfter", e);
+ }
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextup.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextup.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextup.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatNextup.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>Float</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Float</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(float)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatNextup extends EvalFunc<Float>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, nextup value of the argument
+ */
+ public Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+ Float d;
+ try{
+ d = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatRound.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatRound.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatRound.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatRound.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(float) Math.round(float)}.
+* Given a single data atom it Returns the closest long to the argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Float</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Integer</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(float)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatRound extends EvalFunc<Integer>{
+ /**
+ * 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 Integer exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Float d = (Float)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.INTEGER));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatSignum.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatSignum.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatSignum.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatSignum.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(float) Math.signum(float)}.
+* Given a single data atom it Returns the signum function of the argument.
+*
+* <dl>
+* <dt><b>Parameters:</b></dt>
+* <dd><code>value</code> - <code>Float</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Float</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(float)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatSignum extends EvalFunc<Float>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value,
+ * signum function of the argument
+ */
+ @Override
+ public Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Float d = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatUlp.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatUlp.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatUlp.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/FloatUlp.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(float) Math.ulp(float)}.
+* 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>Float</code>.</dd>
+*
+* <dt><b>Return Value:</b></dt>
+* <dd><code>Float</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(float)
+* @see
+* @author ajay garg
+*
+*/
+public class FloatUlp extends EvalFunc<Float>{
+ /**
+ * 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 Float exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Float d = (Float)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.FLOAT));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/HYPOT.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/HYPOT.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/HYPOT.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/HYPOT.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.HYPOT implements a binding to the Java function
+* {@link java.lang.Math#hypot(double,double) Math.hypot(double,double)}.
+* Given a tuple with two data atom Returns sum of squares of two arguments.
+*
+* <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>HYPOT_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.HYPOT(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#hypot(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class HYPOT extends DoubleDoubleBase{
+ Double compute(Double input1, Double input2){
+ return Math.hypot(input1, input2);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IEEEremainder.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IEEEremainder.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IEEEremainder.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IEEEremainder.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.IEEEremainder implements a binding to the Java function
+* {@link java.lang.Math#IEEEremainder(double,double) Math.IEEEremainder(double,double)}.
+* Given a tuple with two data atom it Returns the remainder operation on two
+* arguments as prescribed by the IEEE 754 standard.
+*
+* <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>IEEEremainder_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.IEEEremainder(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#IEEEremainder(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class IEEEremainder extends DoubleDoubleBase{
+ Double compute(Double input1, Double input2){
+ return Math.IEEEremainder(input1, input2);
+
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntAbs.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntAbs.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntAbs.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntAbs.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.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.ABS implements a binding to the Java function
+ * {@link java.lang.Math#abs(double) Math.abs(int)} for computing the
+ * absolute value of the argument. The returned value will be an int which is
+ * absolute value of the input.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>int</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>int</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 IntAbs extends EvalFunc<Integer>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, absolute value of the argument
+ */
+ public Integer exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ Integer d;
+ try{
+ d = (Integer)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.INTEGER));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMax.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMax.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMax.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMax.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 IntMax extends EvalFunc<Integer>{
+ /**
+ * 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 Integer exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Integer first = (Integer)input.get(0);
+ Integer second = (Integer)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.INTEGER));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMin.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMin.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/IntMin.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 IntMin extends EvalFunc<Integer>{
+ /**
+ * 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 Integer exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Integer first = (Integer)input.get(0);
+ Integer second = (Integer)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.INTEGER));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG.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.LOG implements a binding to the Java function
+* {@link java.lang.Math#log(double) Math.log(double)}.
+* Given a single data atom it returns the natural
+* logarithm (base e) 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>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>LOG_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.LOG(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#log(double)
+* @see
+* @author ajay garg
+*
+*/
+public class LOG extends DoubleBase{
+ Double compute(Double input){
+ return Math.log(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG10.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG10.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG10.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG10.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.LOG10 implements a binding to the Java function
+* {@link java.lang.Math#log10(double) Math.log10(double)}.
+* Given a single data atom it returns the base 10 logarithm 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>Double</code> </dd>
+*
+* <dt><b>Return Schema:</b></dt>
+* <dd>LOG10_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.LOG10(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#log10(double)
+* @see
+* @author ajay garg
+*
+*/
+public class LOG10 extends DoubleBase{
+ Double compute(Double input){
+ return Math.log10(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG1P.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG1P.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG1P.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LOG1P.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.LOG1P implements a binding to the Java function
+* {@link java.lang.Math#log1p(double) Math.log1p(double)}.
+* Given a single data atom it Returns the natural logarithm
+* of the sum of the argument and 1.
+*
+* <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>LOG1P_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.LOG1P(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#log1p(double)
+* @see
+* @author ajay garg
+*
+*/
+public class LOG1P extends DoubleBase{
+ Double compute(Double input){
+ return Math.log1p(input);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongAbs.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongAbs.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongAbs.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongAbs.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(long)} for computing the
+ * absolute value of the argument. The returned value will be an long which is
+ * absolute value of the input.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>long</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>long</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 LongAbs extends EvalFunc<Long>{
+ /**
+ * java level API
+ * @param input expects a single numeric value
+ * @param output returns a single numeric value, absolute value of the argument
+ */
+ public Long exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ Long d;
+ try{
+ d = (Long)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.LONG));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMax.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMax.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMax.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMax.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(long,long) Math.max(long,long)} for computing the
+ * the max value of the arguments. The returned value will be an nt which is
+ * the maximum of the inputs.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>2 long values</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>long</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 LongMax extends EvalFunc<Long>{
+ /**
+ * 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 Long exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Long first = (Long)input.get(0);
+ Long second = (Long)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.LONG));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMin.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMin.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMin.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/LongMin.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(long,long) Math.min(long,long)} for computing the
+ * the min value of the arguments. The returned value will be an nt which is
+ * the minimum of the inputs.
+ *
+ * <dl>
+ * <dt><b>Parameters:</b></dt>
+ * <dd><code>value</code> - <code>2 long values</code>.</dd>
+ *
+ * <dt><b>Return Value:</b></dt>
+ * <dd><code>long</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 LongMin extends EvalFunc<Long>{
+ /**
+ * 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 Long exec(Tuple input) throws IOException {
+ if (input == null || input.size() == 0)
+ return null;
+
+ try{
+ Long first = (Long)input.get(0);
+ Long second = (Long)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.LONG));
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MAX.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MAX.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MAX.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MAX.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,107 @@
+/*
+ * 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.MAX implements a binding to the Java function
+* {@link java.lang.Math#max(double,double) Math.max(double,double)}.
+* Given a tuple with two numeric values it returns the
+* large value.
+*
+* <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>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,double)
+* @see
+* @author ajay garg
+*
+*/
+public class MAX extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a tuple containing two numeric DataAtom value
+ * @param output returns a single numeric value, which is
+ * the the larger value among the two.
+ */
+ @Override
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() < 2)
+ return null;
+
+ try{
+ Double first = DataType.toDouble(input.get(0));
+ Double second = DataType.toDouble(input.get(1));
+ return Math.max(first, second);
+ } catch (NumberFormatException nfe){
+ System.err.println("Failed to process input; error - " + nfe.getMessage());
+ return null;
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception in MAX.Initial", e);
+ }
+
+ }
+
+ @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>();
+ Util.addToFunctionList(funcList, this.getClass().getName(), DataType.BYTEARRAY);
+ Util.addToFunctionList(funcList, DoubleMax.class.getName(), DataType.DOUBLE);
+ Util.addToFunctionList(funcList, FloatMax.class.getName(), DataType.FLOAT);
+ Util.addToFunctionList(funcList, IntMax.class.getName(), DataType.INTEGER);
+ Util.addToFunctionList(funcList, LongMax.class.getName(), DataType.LONG);
+
+ return funcList;
+ }
+}
+
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MIN.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MIN.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MIN.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/MIN.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,108 @@
+/*
+ * 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.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.MIN implements a binding to the Java function
+* {@link java.lang.Math#min(double,double) Math.min(double,double)}.
+* Given a tuple with two data atom it Returns the data
+* atom with smaller value.
+*
+* <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>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,double)
+* @see
+* @author ajay garg
+*
+*/
+public class MIN extends EvalFunc<Double>{
+ /**
+ * java level API
+ * @param input expects a tuple containing two numeric DataAtom value
+ * @param output returns a single numeric value, which is
+ * the the smaller value among the two.
+ */
+ @Override
+ public Double exec(Tuple input) throws IOException {
+ if (input == null || input.size() < 2)
+ return null;
+
+ try{
+ Double first = DataType.toDouble(input.get(0));
+ Double second = DataType.toDouble(input.get(1));
+ return Math.min(first, second);
+ } catch (NumberFormatException nfe){
+ System.err.println("Failed to process input; error - " + nfe.getMessage());
+ return null;
+ } catch(Exception e){
+ throw WrappedIOException.wrap("Caught exception in MIN.Initial", e);
+ }
+
+ }
+
+ @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>();
+ Util.addToFunctionList(funcList, this.getClass().getName(), DataType.BYTEARRAY);
+ Util.addToFunctionList(funcList, DoubleMin.class.getName(), DataType.DOUBLE);
+ Util.addToFunctionList(funcList, FloatMin.class.getName(), DataType.FLOAT);
+ Util.addToFunctionList(funcList, IntMin.class.getName(), DataType.INTEGER);
+ Util.addToFunctionList(funcList, LongMin.class.getName(), DataType.LONG);
+
+ return funcList;
+ }
+}
+
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/NEXTUP.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/NEXTUP.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/NEXTUP.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/NEXTUP.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.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 NEXTUP 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 = 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.nextUp(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(DoubleNextup.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.DOUBLE))));
+ funcList.add(new FuncSpec(FloatNextup.class.getName(), new Schema(new Schema.FieldSchema(null, DataType.FLOAT))));
+ return funcList;
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/POW.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/POW.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/POW.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/POW.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.POW implements a binding to the Java function
+* {@link java.lang.Math#pow(double,double) Math.pow(double,double)}.
+* Given a tuple with two data atom it Returns the
+* the value of the first argument raised to the power 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>POW_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.POW(float1);
+* </code></dd>
+* </dl>
+*
+* @see Math#pow(double,double)
+* @see
+* @author ajay garg
+*
+*/
+public class POW extends DoubleDoubleBase{
+ Double compute(Double input1, Double input2){
+ return Math.pow(input1, input2);
+ }
+}
Added: hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RANDOM.java
URL: http://svn.apache.org/viewvc/hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RANDOM.java?rev=709249&view=auto
==============================================================================
--- hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RANDOM.java (added)
+++ hadoop/pig/branches/types/contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/evaluation/math/RANDOM.java Thu Oct 30 14:27:14 2008
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+public class RANDOM extends EvalFunc<Double>{
+
+ public Double exec(Tuple input) throws IOException {
+ return Math.random();
+ }
+
+ @Override
+ public Schema outputSchema(Schema input) {
+ return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input), DataType.DOUBLE));
+ }
+}