hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Halloran (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HADOOP-3567) Test code can create Integer.MIN_INT when trying to create a random non-negative integer
Date Mon, 16 Jun 2008 16:11:45 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-3567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605336#action_12605336
] 

Tim Halloran commented on HADOOP-3567:
--------------------------------------

Actually the below fix might be more concise:

Index: .
===================================================================
--- .	(revision 8259)
+++ .	(working copy)
@@ -97,7 +97,7 @@
       int randomCount = key.get();
 
       for (int i = 0; i < randomCount; i++) {
-        out.collect(new IntWritable(Math.abs(r.nextInt())), new IntWritable(randomVal));
+        out.collect(new IntWritable(r.nextInt(Integer.MAX_VALUE)), new IntWritable(randomVal));
       }
     }
     public void close() {


> Test code can create Integer.MIN_INT when trying to create a random non-negative integer
> ----------------------------------------------------------------------------------------
>
>                 Key: HADOOP-3567
>                 URL: https://issues.apache.org/jira/browse/HADOOP-3567
>             Project: Hadoop Core
>          Issue Type: Bug
>    Affects Versions: 0.17.0
>            Reporter: Tim Halloran
>            Priority: Minor
>
> Sadly, Math.abs returns Integer.MIN_VALUE when passed Integer.MIN_VALUE  Thus the code
in 
> org.apache.hadoop.mapred.TestMapRed appears to need to consider this case.  Patch below.
> Index: .
> ===================================================================
> --- .	(revision 8259)
> +++ .	(working copy)
> @@ -97,7 +97,9 @@
>        int randomCount = key.get();
>  
>        for (int i = 0; i < randomCount; i++) {
> -        out.collect(new IntWritable(Math.abs(r.nextInt())), new IntWritable(randomVal));
> +    	int collectKey = Math.abs(r.nextInt());
> +    	if (collectKey == Integer.MIN_VALUE) collectKey = Integer.MAX_VALUE;
> +        out.collect(new IntWritable(collectKey), new IntWritable(randomVal));
>        }
>      }
>      public void close() {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message