Permalink
Browse files

Collection of Pig Scripts

  • Loading branch information...
1 parent 111172b commit c81a44a9784c48a38b0cd7cc70bd5c7e747d4994 @nvijayap committed Jan 12, 2014
Showing with 32 additions and 0 deletions.
  1. +3 −0 README.md
  2. +13 −0 numbers.pig
  3. +16 −0 numbers.sh
View
@@ -2,3 +2,6 @@ pig
===
Pig Snippets
+
+numbers.pig - shows minimum, average, maximum on each line
+
View
@@ -0,0 +1,13 @@
+data = load 'numbers.txt' as (nmbr:int);
+
+grpd = group data all;
+
+aggs = foreach grpd generate
+ MIN(data.nmbr) as min,
+ AVG(data.nmbr) as avg,
+ MAX(data.nmbr) as max;
+
+aggd = foreach data generate nmbr, aggs.min, aggs.avg, aggs.max;
+
+dump aggd;
+
View
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# creating datafile
+echo "=> Creating datafile ..."
+let n=0
+echo $n >| numbers.txt
+time while [ $n -lt 10000 ]; do
+ let n=n+1
+ echo $n >> numbers.txt
+done
+
+# use local or mapreduce
+echo "=> Running pig ..."
+# pig numbers.pig # default is mapreduce
+time pig -x local numbers.pig
+

0 comments on commit c81a44a

Please sign in to comment.