hadoop - 在 pig 中创建一个巨大的过滤器

标签 hadoop apache-pig

我有这个代码。

large = load 'a super large file' 

CC = FILTER large BY $19 == 'abc OR $20 == 'abc' 
OR $19 == 'def' or $20 == 'def' ....;

OR 条件的数量可以达到 100 甚至数千。

有更好的方法吗?

最佳答案

是的,将这些条件放在另一个文件中。将其加载到关系中并将两个关系连接到列上。如果必须在多个列上进行过滤,则创建与条件一样多的过滤文件。下面是 2 的示例栏目

large = load 'a super large file' 
filter1 = load 'file with values needed to compare with $19';
filter2 = load 'file with values needed to compare with $20';
f1 = JOIN large BY $19,filter1 BY $0;
f2 = JOIN large BY $20,filter2 BY $0;
final = UNION f1,f2;
DUMP final;

您或许可以使用 1 个包含多个列的过滤器文件,并加入这些列以获得不同的过滤结果,然后合并关系。

large = load 'a super large file' 
filter_file = load 'file with values in different columns';

f1 = JOIN large BY $19,filter_file BY $0;
f2 = JOIN large BY $20,filter_file BY $1;
final = UNION f1,f2;
DUMP final;

关于hadoop - 在 pig 中创建一个巨大的过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43532857/

相关文章:

java - hadoop 2.3.0 源码构建错误

hadoop - 如何检查我的集群中使用的 hadoop 发行版?

hadoop - 关于 Pig 作业 Jar 文件

apache-pig - 如何优雅地处理 Pig 中的 null + 数字加法

apache-pig - 如何使用 PIG 中的 MAX 函数检索相应行的最大值?

hadoop - HDFS - 最后一个预期列之后的额外数据

java - 启动NameNode失败

hadoop - avro gradle 插件示例使用

Hadoop 生态系统 - 在我的场景中使用什么技术工具组合? (详情见内)

hadoop - 如何在 Apache Pig 中合并相同关系的行(项目)