You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2008/04/16 01:55:50 UTC
svn commit: r648461 - in
/incubator/pig/branches/types/src/org/apache/pig/data: BagFactory.java
DefaultAbstractBag.java DefaultBagFactory.java SortedDataBag.java
Author: gates
Date: Tue Apr 15 16:55:47 2008
New Revision: 648461
URL: http://svn.apache.org/viewvc?rev=648461&view=rev
Log:
Fix sorted data bag so that local implementation of physical operators can go forward.
Modified:
incubator/pig/branches/types/src/org/apache/pig/data/BagFactory.java
incubator/pig/branches/types/src/org/apache/pig/data/DefaultAbstractBag.java
incubator/pig/branches/types/src/org/apache/pig/data/DefaultBagFactory.java
incubator/pig/branches/types/src/org/apache/pig/data/SortedDataBag.java
Modified: incubator/pig/branches/types/src/org/apache/pig/data/BagFactory.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/data/BagFactory.java?rev=648461&r1=648460&r2=648461&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/data/BagFactory.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/data/BagFactory.java Tue Apr 15 16:55:47 2008
@@ -21,6 +21,7 @@
import java.lang.ClassLoader;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Comparator;
import org.apache.pig.impl.util.SpillableMemoryManager;
@@ -84,11 +85,10 @@
/**
* Get a sorted data bag.
- * @param spec EvalSpec that controls how the data is sorted.
+ * @param comp Comparator that controls how the data is sorted.
* If null, default comparator will be used.
*/
- // TODO FIX Need to pass in comparator
- public abstract DataBag newSortedBag(/*EvalSpec spec*/);
+ public abstract DataBag newSortedBag(Comparator<Tuple> comp);
/**
* Get a distinct data bag.
Modified: incubator/pig/branches/types/src/org/apache/pig/data/DefaultAbstractBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/data/DefaultAbstractBag.java?rev=648461&r1=648460&r2=648461&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/data/DefaultAbstractBag.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/data/DefaultAbstractBag.java Tue Apr 15 16:55:47 2008
@@ -208,9 +208,7 @@
this instanceof DistinctDataBag) {
thisClone = this;
} else {
- // TODO FIX
- // thisClone = new SortedDataBag(null);
- thisClone = new SortedDataBag();
+ thisClone = new SortedDataBag(null);
Iterator<Tuple> i = iterator();
while (i.hasNext()) thisClone.add(i.next());
}
@@ -218,9 +216,7 @@
this instanceof DistinctDataBag) {
otherClone = bOther;
} else {
- // TODO FIX
- //otherClone = new SortedDataBag(null);
- otherClone = new SortedDataBag();
+ otherClone = new SortedDataBag(null);
Iterator<Tuple> i = bOther.iterator();
while (i.hasNext()) otherClone.add(i.next());
}
Modified: incubator/pig/branches/types/src/org/apache/pig/data/DefaultBagFactory.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/data/DefaultBagFactory.java?rev=648461&r1=648460&r2=648461&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/data/DefaultBagFactory.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/data/DefaultBagFactory.java Tue Apr 15 16:55:47 2008
@@ -17,6 +17,8 @@
*/
package org.apache.pig.data;
+import java.util.Comparator;
+
import org.apache.pig.impl.util.SpillableMemoryManager;
/**
@@ -35,17 +37,13 @@
/**
* Get a sorted data bag.
- * @param spec EvalSpec that controls how the data is sorted.
+ * @param comp Comparator that controls how the data is sorted.
* If null, default comparator will be used.
*/
- // TODO FIX Need to pass in comparator
- public DataBag newSortedBag(/*EvalSpec spec*/) {
- /*
- DataBag b = new SortedDataBag(spec);
+ public DataBag newSortedBag(Comparator<Tuple> comp) {
+ DataBag b = new SortedDataBag(comp);
registerBag(b);
return b;
- */
- return null;
}
/**
Modified: incubator/pig/branches/types/src/org/apache/pig/data/SortedDataBag.java
URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/data/SortedDataBag.java?rev=648461&r1=648460&r2=648461&view=diff
==============================================================================
--- incubator/pig/branches/types/src/org/apache/pig/data/SortedDataBag.java (original)
+++ incubator/pig/branches/types/src/org/apache/pig/data/SortedDataBag.java Tue Apr 15 16:55:47 2008
@@ -66,19 +66,11 @@
}
/**
- * @param spec EvalSpec to use to do the sorting. spec.getComparator()
- * will be called to populate our mComp field. If null,
+ * @param comp Comparator to use to do the sorting. If null,
* DefaultComparator will be used.
*/
- // TODO FIX Need to pass in comparator from somewhere.
- public SortedDataBag(/*EvalSpec spec*/) {
- /*
- if (spec == null) {
- mComp = new DefaultComparator();
- } else {
- mComp = spec.getComparator();
- }
- */
+ public SortedDataBag(Comparator<Tuple> comp) {
+ mComp = (comp == null) ? new DefaultComparator() : comp;
mContents = new ArrayList<Tuple>();
}