Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> how to operate a map type


Copy link to this message
-
how to operate a map type
Hi all,

I have the below pig code:

register /home/uu/project/lib/pigudfs.jar
ruls = load 'testurl' as (url:chararray);

b = foreach ruls generate com.company.pig.GetURLContent($0,3,0.1);

here when dump b, it will return:
([4#0.1677963])
([193#0.16985779,81#0.10994483])
([418#0.14138427,9#0.1107544,282#0.18699136])

I just want group by the map key and sum the map value just like:
c = group b by $0#key;
d = foreach c generate group,SUM(b.$0#value);

How could I write the code?

Thanks,
Jameson Li.
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB