-
Notifications
You must be signed in to change notification settings - Fork 0
/
udf.sh
executable file
·29 lines (24 loc) · 1.04 KB
/
udf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
if [ "$1" == "" ]; then
echo "Usage: $0 <java file>"
exit 1
fi
CNAME=${1%.java}
JARNAME=$CNAME.jar
JARDIR=$CNAME
CLASSPATH=$(ls lib/hive-serde-*.jar):$(ls lib/hive-exec-*.jar):$(ls lib/hadoop-core-*.jar):$(ls lib/maxmindgeoip.jar)
function tell {
echo
echo "$1 successfully compiled. In Hive run:"
echo "$> add jar $JARNAME;"
echo "$> create temporary function $CNAME as 'com.example.hive.udf.$CNAME';"
echo
}
mkdir -p $JARDIR
javac -classpath $CLASSPATH -d $JARDIR/ $1 && jar -cf $JARNAME -C $JARDIR/ . && tell $1
#./udf.sh src/com/mozilla/hive/GenericUDFGeoIP.java && scp src/com/mozilla/hive/GenericUDFGeoIP.jar [email protected]:/home/aphadke/
#add file GeoIPCityNew.dat;
#add jar /home/aphadke/GenericUDFGeoIP.jar;
#add jar /home/aphadke/maxmindgeoip.jar;
#create temporary function g as 'com.mozilla.hive.GenericUDFGeoIP';
#select g(ip_address, 'COUNTRY_NAME', './GeoIPCityNew.dat' ) from research_logs where ds='2012-06-05' and domain='www.mozilla.com' and ip_address != 'null' limit 10;