Share Ideas, Start Something Good.

This topic contains 0 replies, has 1 voice, and was last updated by  chakrapani 3 years, 10 months ago.

Viewing 1 post (of 1 total)
• Author
Posts
• #434

chakrapani
Participant

Hl All,I have tried to write pig scripts for the assignments
1)Max temperature
——————
temp = LOAD ‘/Temperature’ USING PigStorage (‘ ‘)as (year:int,t:int);
temp_group = GROUP temp BY year;
temp_year_max = FOREACH temp_group GENERATE group,MAX(temp.t);
tore temp_year_max INTO ‘/temp_year_max_pig’;

2) Word Count
———————
word_temp = LOAD ‘/wordcountproblem’ as (words:chararray);
word_split = FOREACH word_temp GENERATE FLATTEN(TOKENIZE(words)) as word;
word_group = GROUP word_split BY word;
word_count = FOREACH word_group GENERATE COUNT(word_split), group;
store word_count into ‘/wordcount_pig’;

3) Word Size
————-
word_temp = LOAD ‘/wordcountproblem’ as (words:chararray);
word_split = FOREACH word_temp GENERATE FLATTEN(TOKENIZE(words)) as word;
word_group = GROUP word_split BY SIZE(word);
word_size = FOREACH word_group GENERATE COUNT(word_split), group;
store word_size into ‘/wordsize_pig’;

4) Patents
———–
p_temp = LOAD ‘/patent’ USING PigStorage (‘ ‘)as (p:int,sp:float);
p_group = GROUP p_temp BY p;
p_count = FOREACH p_group GENERATE group, COUNT(p_temp.sp);
store p_count INTO ‘/patent_count_pig’;

please correct me if any thing is wrong or better way to do these.
—-
Thanks
Chakrapani

Viewing 1 post (of 1 total)

The forum ‘General Discussion’ is closed to new topics and replies.