Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-176

comparators of integral writable types are not transitive for inequalities

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.6.0
    • io
    • None
    • red hat

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            dking Dick King
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: