Return-Path: Delivered-To: apmail-pig-commits-archive@www.apache.org Received: (qmail 38100 invoked from network); 4 Oct 2010 21:38:32 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Oct 2010 21:38:32 -0000 Received: (qmail 27323 invoked by uid 500); 4 Oct 2010 21:38:32 -0000 Delivered-To: apmail-pig-commits-archive@pig.apache.org Received: (qmail 27266 invoked by uid 500); 4 Oct 2010 21:38:32 -0000 Mailing-List: contact commits-help@pig.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pig.apache.org Delivered-To: mailing list commits@pig.apache.org Received: (qmail 27259 invoked by uid 500); 4 Oct 2010 21:38:32 -0000 Delivered-To: apmail-hadoop-pig-commits@hadoop.apache.org Received: (qmail 27254 invoked by uid 500); 4 Oct 2010 21:38:32 -0000 Delivered-To: apmail-incubator-pig-commits@incubator.apache.org Received: (qmail 27247 invoked by uid 99); 4 Oct 2010 21:38:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 21:38:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 21:38:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4131B23888D7; Mon, 4 Oct 2010 21:38:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1004443 - in /hadoop/pig/trunk: CHANGES.txt src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/partitioners/DiscreteProbabilitySampleGenerator.java Date: Mon, 04 Oct 2010 21:38:08 -0000 To: pig-commits@incubator.apache.org From: rding@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101004213808.4131B23888D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 cm = new CountingMap(); for(int i=0;i<100;i++){ cm.put(gen.getNext(), 1);