DEFINE alias GenericInvoker(String fullName)2. Terms
DEFINE alias GenericInvoker(String fullName, String paramSpecsStr)
DEFINE alias GenericInvoker(String fullName, String paramSpecsStr, String isStatic)
alias: UDF 함수 이름 지정
GenericInvoker: return type에 따라 InvokeForInt, InvokeForLong, InvokeForFloat, InvokeForDouble, InvokeForString 중 택 1
fullName: Java Method 지정
paramSpecsStr: 매개변수 type 지정
isStatic: Static 여부 지정, Default = 'true'
3. Example 1
decimal to hexadecimal
DEFINE IntToHex InvokeForString('java.lang.Integer.toHexString', 'int');
pvd = load 'PageViewData' as (exchange, symbol, date, open, high, low, close, volume, str_hex);
inhex = foreach pvd {
generate symbol, IntToHex((int)volume);
}
4. Example 2
hexadecimal to decimal ( Long )
DEFINE Hex2Long InvokeForLong('java.lang.Long.parseLong', 'String int');
pvd = load 'PageViewData' as (exchange, symbol, date, open, high, low, close, volume, str_hex);
hexLong = foreach pvd {
generate symbol, Hex2Long(str_hex, 16);
}
5. 참고 link
https://www.safaribooksonline.com/library/view/programming-pig/9781449317881/ch05s04.html
http://pig.apache.org/docs/r0.10.0/api/org/apache/pig/builtin/GenericInvoker.html
http://www.tutorialspoint.com/java/lang/long_parselong_radix.htm
댓글 없음:
댓글 쓰기