猪传递关系作为UDF的参数 [英] Pig pass relation as argument to UDF

查看:131
本文介绍了猪传递关系作为UDF的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在PIG中传递一个UDF关系

I need to pass a relation to a UDF in PIG

 articles = load x using ...;
 groupedArticles = udfs.MyUDF(articles);

是这样的可能吗?任何解决方法?

Is something like this possible? Any workaround?

谢谢

thanks

推荐答案

与UDF有关的所有领域?传递关系是没有意义的。在任何情况下,这取决于你的加载语句的样子。如果你将每个条目加载为 load x using ... as(entry:(a:int,b:chararray,...))到UDF就像 groupedArticles = foreach articles generate udfs.MyUDF(entry)将整行作为一个元组传递可能是最通用的方法,你必须处理一个通用元组尽管你的UDF。

I guess you mean to pass all fields of the relation to the UDF? Passing the relation would not make sense. In any case this depends on how your load statement looks like. If you load each entry as a tuple load x using ... as (entry:(a:int, b:chararray, ...)) than you could pass that to the UDF like groupedArticles = foreach articles generate udfs.MyUDF(entry) Passing the whole line as a tuple is probably the most generic way, you have to deal with a generic tuple in your UDF though.

这篇关于猪传递关系作为UDF的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆