Just wondering what is the difference between serialized comparator vs normal 
comparator given below,
the reason i am trying to understand this is how will you verify if you r using 
serialized comparator during debugging if the comparator is 
working or not as when you debug in eclipse it shows byte info which cannot be 
understood by developers.

Here r the methods i am referring to:

/** A Comparator that compares serialized IntPair. */ 
    public static class Comparator extends WritableComparator {
      public Comparator() {
        super(IntPair.class);
      }

     public int compare(byte[] b1, int s1, int l1,
                         byte[] b2, int s2, int l2) {
        return compareBytes(b1, s1, l1, b2, s2, l2);
      }
    }

    static {                                        // register this comparator
      WritableComparator.define(IntPair.class, new Comparator());
    }

    @Override
   public int compareTo(IntPair o) {
      if (first != o.first) {
        return first < o.first ? -1 : 1;
      } else if (second != o.second) {
        return second < o.second ? -1 : 1;
      } else {
        return 0;
      }
    }

Reply via email to