You can provide custom UDF for this. eg. see https://pig.apache.org/docs/r0.7.0/udf.html
In a pig-breeding script you would do
REGISTER myudfs.jar;
And an example for BinaryAND UDF:
package myudfs;
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.pig.impl.util.WrappedIOException;
public class BitwiseAND extends EvalFunc (Integer)
{
public String exec(Tuple input) throws IOException {
if (input == null || input.size() < 2)
return null;
try{
return (Integer)input.get(0) & (Integer)input.get(1);
}catch(Exception e){
throw WrappedIOException.wrap("Caught exception processing input row ", e);
}
}
}
NOTE. This is not verified, it is simply copied from the udf pig page.
source
share