2014-08-08

Pig: Distinct

Distinct主要是去掉重复的记录,是对条记录进行去重,而不是对单个某个schema。

daily = load 'NYSE_daily' as (exchange:chararray, symbol:chararray);
uniq = distinct daily

它需要收集相似的记录在一块,判断这些记录是否是重复的。我的理解是:在reduce收集相似的记录在一块,充分利用了combiner去掉重复的记录,在map里面进行删除。(有点奇怪的理解)

等价于SQL中的:

select distinct x

如果想对某个schema进行distinct,可以先选出来。

SQL的实现原理:

http://blog.codinglabs.org/articles/theory-of-mysql-index.html

C++:

http://man.chinaunix.net/develop/c&c++/c/c.htm#_Toc520634042

原文地址:https://www.cnblogs.com/leewiki/p/3900121.html