Hi, guys,
I am using hadoop 0.20.2, and I am trying to run the "SecondarySort" exmaple.
The following is the "FirstGroupingComparator" class, and I just cannot figure
out how "WritableComparator.compareBytes(b1, s1, Integer.SIZE / 8, b2, s2,
Integer.SIZE / 8)" works. There are really few javadocs of this class or this
method.
1. Why it is "Integer.SIZE / 8"?
2. If I want to compare two "String" here, how should I write to code?
public static class FirstGroupingComparator implements
RawComparator<IntPair> {
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int
l2) {
int ret = WritableComparator.compareBytes(b1, s1, Integer.SIZE / 8,
b2, s2, Integer.SIZE / 8);
return ret;
}
@Override
public int compare(IntPair o1, IntPair o2) {
int l = o1.getFirst();
int r = o2.getFirst();
return l == r ? 0 : (l < r ? -1 : 1);
}
}
Thanks.
Dennis