Demo entry 2830835



Submitted by test on Oct 07, 2015 at 23:19
Language: Pig. Code size: 1.2 kB.

movies = LOAD '/Users/pedro/BigData/HW1/pig/movies/data/movies_data.csv' USING PigStorage(',') AS (id,name,year,rating,duration);

/* 1.1. Filter: List the movies that were released between 1950 and 1960. */
movies_50s = FILTER movies BY (float)year>1949 AND (float)year<1961;
STORE movies_50s INTO '/Users/pedro/BigData/HW1/pig/movies/results/1-1-movies_50s';

/* 1.2. Filter: List the movies that last more than 2 hours. */
movies_long = FILTER movies BY (float)duration>7200;
STORE movies_long INTO '/Users/pedro/BigData/HW1/pig/movies/results/1-2-movies_long';

/* 1.3. Filter: List the movies that have a rating between 3 and 4. */
movies_rating_3_4 = FILTER movies BY (float)rating>3 AND (float) rating <4;
STORE movies_rating_3_4 INTO '/Users/pedro/BigData/HW1/pig/movies/results/1-3movies_rating_3_4';

/* 2. Foreach Generate: List movie names and their duration (in hours). */
movies_duration = foreach movies generate name, (float)duration/3600;
STORE movies_duration INTO '/Users/pedro/BigData/HW1/pig/movies/results/2-movies_duration';

/* 3. List all movies in descending order of year. */
movies_year_sort = ORDER movies BY year DESC;
STORE movies_year_sort INTO '/Users/pedro/BigData/HW1/pig/movies/results/3-movies_year_sort';

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).