You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Dick King (JIRA)" <ji...@apache.org> on 2006/04/29 01:25:41 UTC
[jira] Created: (HADOOP-176) comparators of integral writable types
are not transitive for inequalities
comparators of integral writable types are not transitive for inequalities
--------------------------------------------------------------------------
Key: HADOOP-176
URL: http://issues.apache.org/jira/browse/HADOOP-176
Project: Hadoop
Type: Bug
Components: io
Environment: red hat
Reporter: Dick King
Consider the following code from IntWritable.java :
public int compare(byte[] b1, int s1, int l1,
byte[] b2, int s2, int l2) {
int thisValue = readInt(b1, s1);
int thatValue = readInt(b2, s2);
return thisValue - thatValue;
}
If a Java Runtime subtracts 20 from -(2^31 - 10) it gets a huge positive number, not the negative value that the comparator should return.
LongWritable does this right, of course.
That last line should be
return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));
-dk
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Resolved: (HADOOP-176) comparators of integral writable
types are not transitive for inequalities
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/HADOOP-176?page=all ]
Doug Cutting resolved HADOOP-176.
---------------------------------
Fix Version/s: 0.6.0
Resolution: Fixed
I just committed this. Thanks, Dick.
> comparators of integral writable types are not transitive for inequalities
> --------------------------------------------------------------------------
>
> Key: HADOOP-176
> URL: http://issues.apache.org/jira/browse/HADOOP-176
> Project: Hadoop
> Issue Type: Bug
> Components: io
> Environment: red hat
> Reporter: Dick King
> Fix For: 0.6.0
>
>
> Consider the following code from IntWritable.java :
> public int compare(byte[] b1, int s1, int l1,
> byte[] b2, int s2, int l2) {
> int thisValue = readInt(b1, s1);
> int thatValue = readInt(b2, s2);
> return thisValue - thatValue;
> }
> If a Java Runtime subtracts 20 from -(2^31 - 10) it gets a huge positive number, not the negative value that the comparator should return.
> LongWritable does this right, of course.
> That last line should be
> return (thisValue<thatValue ? -1 : (thisValue==thatValue ? 0 : 1));
> -dk
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira