You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by rd...@apache.org on 2010/10/04 23:38:08 UTC
svn commit: r1004443 - in /hadoop/pig/trunk: CHANGES.txt
src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java
Author: rding
Date: Mon Oct 4 21:38:07 2010
New Revision: 1004443
URL: http://svn.apache.org/viewvc?rev=1004443&view=rev
Log:
PIG-1662: Need better error message for MalFormedProbVecException
Modified:
hadoop/pig/trunk/CHANGES.txt
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java
Modified: hadoop/pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=1004443&r1=1004442&r2=1004443&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Oct 4 21:38:07 2010
@@ -209,6 +209,8 @@ PIG-1309: Map-side Cogroup (ashutoshc)
BUG FIXES
+PIG-1662: Need better error message for MalFormedProbVecException (rding)
+
PIG-1656: TOBAG udfs ignores columns with null value; it does not use input type
to determine output schema (thejas)
Modified: hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java?rev=1004443&r1=1004442&r2=1004443&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java Mon Oct 4 21:38:07 2010
@@ -26,22 +26,7 @@ public class DiscreteProbabilitySampleGe
Random rGen;
float[] probVec;
float epsilon = 0.00001f;
-
- public DiscreteProbabilitySampleGenerator(long seed, float[] probVec) throws MalFormedProbVecException{
- rGen = new Random(seed);
- float sum = 0.0f;
- for (float f : probVec) {
- sum += f;
- }
- if(1-epsilon<=sum && sum<=1+epsilon)
- this.probVec = probVec;
- else {
- int errorCode = 2122;
- String message = "Sum of probabilities should be one";
- throw new MalFormedProbVecException(message, errorCode, PigException.BUG);
- }
- }
-
+
public DiscreteProbabilitySampleGenerator(float[] probVec) throws MalFormedProbVecException{
rGen = new Random();
float sum = 0.0f;
@@ -52,7 +37,7 @@ public class DiscreteProbabilitySampleGe
this.probVec = probVec;
else {
int errorCode = 2122;
- String message = "Sum of probabilities should be one";
+ String message = "Sum of probabilities should be one: " + Arrays.toString(probVec);
throw new MalFormedProbVecException(message, errorCode, PigException.BUG);
}
}
@@ -78,7 +63,7 @@ public class DiscreteProbabilitySampleGe
public static void main(String[] args) throws MalFormedProbVecException {
float[] vec = { 0, 0.3f, 0.2f, 0, 0, 0.5f };
- DiscreteProbabilitySampleGenerator gen = new DiscreteProbabilitySampleGenerator(11317, vec);
+ DiscreteProbabilitySampleGenerator gen = new DiscreteProbabilitySampleGenerator(vec);
CountingMap<Integer> cm = new CountingMap<Integer>();
for(int i=0;i<100;i++){
cm.put(gen.getNext(), 1);