[
https://issues.apache.org/jira/browse/HADOOP-3378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jingkei Ly updated HADOOP-3378:
-------------------------------
Attachment: hadoop-bug.csv
The output I get from this input is:
10098 10098
110098 110098
200098 200098
210098 210098
14205001 14205001
17380002 17380002
17380002 17380002
27470011 27470011
57370011 57370011
60940011 60940011
86210011 86210011
110660011 110660011
4428640021 4428640021
4428640021 4428640021
135890011 135890011
214850001 214850001
354970011 354970011
The expected output should be:
10098 10098
110098 110098
200098 200098
210098 210098
14205001 14205001
17380002 17380002
17380002 17380002
27470011 27470011
57370011 57370011
60940011 60940011
86210011 86210011
110660011 110660011
135890011 135890011
214850001 214850001
354970011 354970011
4428640021 4428640021
4428640021 4428640021
> Incorrect sort order if WritableComparable.compareTo() does not return -1, 0
> or 1
> ---------------------------------------------------------------------------------
>
> Key: HADOOP-3378
> URL: https://issues.apache.org/jira/browse/HADOOP-3378
> Project: Hadoop Core
> Issue Type: Bug
> Components: io
> Affects Versions: 0.16.3
> Reporter: Jingkei Ly
> Priority: Minor
> Attachments: hadoop-bug.csv, Sort.java
>
>
> I've found that incorrect sort orders are returned in some cases if the
> WritableComparable.compareTo() method doesn't return -1, 0 or 1.
> I believe this is a bug as the compareTo() interface states that the returned
> int be only a -ve or +ve number, and will potentially catch a lot of people
> out who decide to write a WritableComparator (well it caught me out anyway!).
> I'll attach an example application to demonstrate -- I simply modified the
> sort example to specify a non-default comparator to sort LongWritable , i.e.:
> {quote}
> public int compare(WritableComparable a, WritableComparable b) {
> LongWritable longA =(LongWritable) a;
> LongWritable longB =(LongWritable) b;
>
> return (int) (longA.get() - longB.get()); // wrong sort order
> // return (int) Math.signum(longA.get() - longB.get()); // correct
> sort order
> }
> {quote}
> When I run the application through Hadoop on my input data it returns the
> incorrect sort order.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.