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

查看:26
本文介绍了Pig pass 关系作为 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?

谢谢

推荐答案

我猜你的意思是将关系的所有字段传递给 UDF?传递关系没有意义.在任何情况下,这都取决于您的 load 语句的外观.如果您将每个条目作为元组加载 load x using ... as (entry:(a:int, b:chararray, ...)) 那么您可以将其传递给 UDF,如 groupedArticles = foreach 文章生成 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.

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

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