Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Pig Wiki" for change 
notification.

The "TuringCompletePig" page has been changed by AlanGates.
http://wiki.apache.org/pig/TuringCompletePig?action=diff&rev1=5&rev2=6

--------------------------------------------------

      }
  }}}
  
+ == Approach 3 ==
+ At the Pig contributor workshop in June 2010 Dmitriy Ryaboy proposed that we 
go the DSL route in Java.  Thus the example given above becomes something like:
+ 
+ {{{
+ 
+ public class Main {
+ 
+     public static void main(String[] args) {
+         float error = 100.0;
+         String infile = "original.data";
+         PigBuilder pig = new PigBuilder();
+         while (error > 1.0) {
+             PigRelation A = pig.load(infile, "piggybank.MyLoader");
+             PigRelation B = A.group(pig.ALL);
+             // It's not entirely clear to me how nested foreach works in this 
scenario
+             PigRelation C = B.foreach(new MyFunc("A"));
+        
+             PigIterator pi = pig.openIterator(C, "outfile");
+             Tuple t = pi.next();
+             error = t.get(1);
+             if (error >= 1.0) {
+                 pig.fs.mv('outfile', 'infile');
+             }
+         }
+     }
+ }
+ }}}
+ 
+ This would be accomplished by creating a public interface for Pig operators 
(here called !PigBuilder, but I'm not proposing that as the actual name) that 
would
+ construct a logical plan and execute it when openIterator is called, much as 
!PigServer does today.  Another way to look at this is !PigServer could be 
changed to
+ expose Pig operators instead of just strings as it does today.  
+ 
+ The beauty of doing this in Java is it facilitates it being used in scripting 
languages as well.  Since Java packages can be directly imported into Jython, 
JRuby,
+ Groovy, and other languages this immediately provides a scripting interface 
in the language of the users choice.
+ 
+ This does violate requirement 10 above (that Pig Latin should appear the same 
in embedded and non-embedded form), but the cross language functionality may be 
worth
+ it.
+ 

Reply via email to