Skip to Main Content
Hadoop数据分析
book

Hadoop数据分析

by Benjamin Bengfort, Jenny Kim
April 2018
Intermediate to advanced content levelIntermediate to advanced
229 pages
6h 19m
Chinese
Posts & Telecom Press
Content preview from Hadoop数据分析
144
8
public String exec(Tuple args)throws IOException {
if (args == null || args.size() == 0) {
return false;
}
try {
Object object = args.get(0);
if (object == null) {
return false;
}
int i = (Integer)object;
if (i >= 0) {
return new String("POSITIVE");
} else {
return new String("NEGATIVE");
}
} catch (ExecException e) {
throw new IOException(e);
}
}
}
要使用此函数,就需要先编译它,将它打包成
JAR
文件,然后使用 REGISTER 运算符将它
注册到
Pig
grunt> REGISTER statistics-pig.jar;
然后通过命令调用该函数:
grunt> classified = FOREACH sentiment_score GENERATE id,
com.statistics.pig.Classify(final) AS classification, final AS score;
建议你阅读
UDF
的相关文档,其中包含支持的
UDF
接口列表,并提供用于评估、加
载、存储、汇总 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kudu:构建高性能实时数据分析存储系统

Kudu:构建高性能实时数据分析存储系统

Jean-Marc Spaggiari, Mladen Kovacevic, Brock Noland, Ryan Bosshart
Java并发编程实战

Java并发编程实战

Brian Goetz, Tim Peierls
面向机器学习的自然语言标注

面向机器学习的自然语言标注

James Pustejovsky, Amber Stubbs

Publisher Resources

ISBN: 9787115479648