pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r612144 - in /incubator/pig/trunk: CHANGES.txt src/org/apache/pig/data/DataBag.java
Date Tue, 15 Jan 2008 16:07:05 GMT
Author: gates
Date: Tue Jan 15 08:06:56 2008
New Revision: 612144

URL: http://svn.apache.org/viewvc?rev=612144&view=rev
Log:
PIG-56: Made DataBag implement Iterable. (groves via gates)


Modified:
    incubator/pig/trunk/CHANGES.txt
    incubator/pig/trunk/src/org/apache/pig/data/DataBag.java

Modified: incubator/pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/CHANGES.txt?rev=612144&r1=612143&r2=612144&view=diff
==============================================================================
--- incubator/pig/trunk/CHANGES.txt (original)
+++ incubator/pig/trunk/CHANGES.txt Tue Jan 15 08:06:56 2008
@@ -65,3 +65,4 @@
 	PIG-61: Fixed MapreducePlanCompiler to use PigContext to load up the
 	comparator function instead of Class.forName.  (gates)
 
+	PIG-56: Made DataBag implement Iterable. (groves via gates)

Modified: incubator/pig/trunk/src/org/apache/pig/data/DataBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/trunk/src/org/apache/pig/data/DataBag.java?rev=612144&r1=612143&r2=612144&view=diff
==============================================================================
--- incubator/pig/trunk/src/org/apache/pig/data/DataBag.java (original)
+++ incubator/pig/trunk/src/org/apache/pig/data/DataBag.java Tue Jan 15 08:06:56 2008
@@ -65,7 +65,7 @@
  * DataBag come in several types, default, sorted, and distinct.  The type
  * must be chosen up front, there is no way to convert a bag on the fly.
  */
-public abstract class DataBag extends Datum implements Spillable {
+public abstract class DataBag extends Datum implements Spillable, Iterable<Tuple> {
     // Container that holds the tuples. Actual object instantiated by
     // subclasses.
     protected Collection<Tuple> mContents;
@@ -140,8 +140,9 @@
         synchronized (mContents) {
             mMemSizeChanged = true;
             mSize += b.size();
-            Iterator<Tuple> i = b.iterator();
-            while (i.hasNext()) mContents.add(i.next());
+            for (Tuple t : b) {
+               mContents.add(t);
+            }
         }
     }
 
@@ -278,10 +279,8 @@
         // time re-sorting or re-applying distinct.
         out.write(BAG);
         out.writeLong(size());
-        Iterator<Tuple> it = iterator();
-        while (it.hasNext()) {
-            Tuple item = it.next();
-            item.write(out);
+        for (Tuple t : this) {
+            t.write(out);
         }    
     }
  



Mime
View raw message