嵌入式 hadoop-pig:为 UDF 使用自动 addContainingJar 的正确方法是什么? [英] embedded hadoop-pig: what's the correct way to use the automatic addContainingJar for UDFs?

查看:17
本文介绍了嵌入式 hadoop-pig:为 UDF 使用自动 addContainingJar 的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用 pigServer.registerFunction 时,您不应该显式调用 pigServer.registerJar,而是让 pig 使用 jarManager.findContainingJar 自动检测 jar.

when you use pigServer.registerFunction, you're not supposed to explicitly call pigServer.registerJar, but rather have pig automatically detect the jar using jarManager.findContainingJar.

但是,我们有一个复杂的 UDF,它的类依赖于来自多个 jar 的其他类.所以我们用 maven-assembly 创建了一个 jar-with-dependencies.但这会导致整个 jar 进入 pigContext.skipJars(因为它包含 pig.jar 本身)并且没有被发送到 hadoop 服务器:(

However, we have a complex UDF who's class is dependent on other classes from multiple jars. So we created a jar-with-dependencies with the maven-assembly. But this causes the entire jar to enter pigContext.skipJars (as it contains the pig.jar itself) and not being sent to the hadoop server :(

这里的正确方法是什么?我们必须为我们依赖的每个 jar 手动调用 registerJar 吗?

What's the correct approach here? Must we manually call registerJar for every jar we depend on?

推荐答案

不确定认证方式是什么,但这里有一些提示:

not sure what's the certified way, but here's some pointers:

  • 当您使用 pigServer.registerFunction 时,pig 会自动检测包含 udfs 的 jar 并将其发送到 jobTracker
  • pig 还会自动检测包含 PigMapReduce 类 (JarManager.createJar) 的 jar,并从中提取org/apache/开头的类pigorg/antlr/runtime 等,并将它们也发送到 jobTracker
  • 因此,如果您的 UDF 与 PigMapReduce 位于同一个 jar 中,那么您就搞砸了,因为它不会被发送
  • 我们的结论:不要使用 jar-with-dependencies
  • when you use pigServer.registerFunction pig automatically detects the jar that contain the udfs and sends it to the jobTracker
  • pig also automatically detects the jar that contains PigMapReduce class (JarManager.createJar), and extracts from it only the classes that start with org/apache/pig, org/antlr/runtime, etc. and sends them to the jobTracker as well
  • so, if your UDF sits in the same jar as PigMapReduce your'e screwed, because it won't get sent
  • our conclusion: don't use jar-with-dependencies

HTH

这篇关于嵌入式 hadoop-pig:为 UDF 使用自动 addContainingJar 的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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