-
-
Save leepro/6402440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set Sort Comparator Class in the Driver code | |
job.setSortComparatorClass(SortFloatComparator.class); | |
// Write a Sort Comparator and save as "SortFloatComparator.java" | |
import java.io.*; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.io.WritableComparable; | |
import org.apache.hadoop.io.WritableComparator; | |
public class SortFloatComparator extends WritableComparator { | |
//Constructor. | |
protected SortFloatComparator() { | |
super(Text.class, true); | |
} | |
@SuppressWarnings("rawtypes") | |
@Override | |
public int compare(WritableComparable w1, WritableComparable w2) { | |
String k1 = ((Text)w1).toString(); | |
String k2 = ((Text)w2).toString(); | |
return -1 * k1.compareTo(k2); | |
} | |
} | |
// Mapper and Reducer Codes here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment