Created
March 22, 2012 14:51
-
-
Save tf0054/2158764 to your computer and use it in GitHub Desktop.
Hack#48
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.hadoophacks.pig2; | |
import org.apache.pig.EvalFunc; | |
import org.apache.pig.data.Tuple; | |
import org.apache.pig.data.DataType; | |
import org.apache.pig.backend.executionengine.ExecException; | |
import org.apache.pig.impl.logicalLayer.schema.Schema; | |
import org.apache.pig.impl.logicalLayer.FrontendException; | |
import java.io.IOException; | |
import java.util.List; | |
import java.util.ArrayList; | |
import org.apache.pig.FuncSpec; | |
public class DoubleAbs extends EvalFunc<Double>{ | |
public Double exec(Tuple input)throws IOException{ | |
if(input == null || input.size() == 0){ | |
return null; | |
} | |
try{ | |
Double value = (Double)input.get(0); | |
return Math.abs(value); | |
}catch(ExecException e){ | |
throw new IOException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment