WritableComparator is a general implementation of hadoop provided interface RawComparator for WritableComparable classes.
it provides a default implementation of the raw compare() method that deserializes the objects to be compared from the stream and invokes the object compare() method.
WritableComparator can be used to compare two IntWritable objects as shown below.
Java
RawComparator<IntWritable> comparator = WritableComparator.get(IntWritable.class);IntWritable int1 = new IntWritable(150);
IntWritable int2 = new IntWritable(100);
if (comparator.compare(int1, int2) > 0) //true
{
}