I am trying to compile this UDF:
package com.dataminelab.hive.udf;
import org.apache.hadoop.hive.ql.exec.UDF;
import org.apache.hadoop.io.Text;
import java.security.*;
/**
* Calculate md5 of the string
*/
public final class Md5 extends UDF {
public Text evaluate(final Text s) {
if (s == null) {
return null;
}
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(s.toString().getBytes());
byte[] md5hash = md.digest();
StringBuilder builder = new StringBuilder();
for (byte b : md5hash) {
builder.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
}
return new Text(builder.toString());
} catch (NoSuchAlgorithmException nsae) {
System.out.println("Cannot find digest algorithm");
System.exit(1);
}
return null;
}
}
Trying to compile with:
javac Md5.java
But I get:
Md5.java:2: package org.apache.hadoop.hive.ql.exec does not exist
import org.apache.hadoop.hive.ql.exec.UDF;
^
Md5.java:3: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
I assume these are in a jar file somewhere but I'm not sure where hadoop install them to so I can't add them to my classpath. Does anyone know the default location or how to find out?