我有一张桌子上有这个人的名字,他去哪里购物。我想找到具有超市名称的每个人的最大出现次数。
例如,在下面的文件中,如果Alan去Costco购物的最大次数,那么输出应该有他的商店名称和名称以及他去那里的次数。我需要在下面给出的文件中为所有人找到这个计数。
Alan Costco
Ryan Walmart
Jim Costco
Steve WholeFoods
Ryan WholeFoods
Jim Walmart
Alan Costco
Ryan Walmart
Jim Costco
Steve WholeFoods
Ryan WholeFoods
Jim Walmart
Alan Costco
Ryan Walmart
Jim Costco
Steve WholeFoods
Ryan WholeFoods
Jim Walmart
Alan Costco
Ryan Walmart
Jim Costco
Steve WholeFoods
Ryan WholeFoods
Jim Walmart
Alan Costco
Ryan Walmart
Jim Costco
Steve WholeFoods
Ryan WholeFoods
Jim Walmart
Alan Walmart
Jim WholeFoods
Ryan Costco
Steve Walmart
答案 0 :(得分:0)
shopdata = LOAD 'path_of_filename' USING PigStorage(',') as (name:bytearray,mall:bytearray);
groupdata = group shopdata by (name,mall);
reqdata = foreach groupdata generate group.name as customer,group.mall as shopping_mall,COUNT(shopdata.mall);
dump reqdata;
答案 1 :(得分:0)