hadoop - How to implement WritableComparable interface? -
i need use method setgroupingcomparatorclass in job , takes argument of type writablecomparable.
i unable implement writablecomparable class.
please me solve this. regards, bidyut
setgroupingcomparatorclass(class<? extends rawcomparator> cls) define comparator controls keys grouped single call reducer.reduce(object, iterable, org.apache.hadoop.mapreduce.reducer.context)
job.setgroupingcomparatorclass(customkey.groupcomparator.class); in customkey class can write static method.
add below code in custom key class.
public class customkey implements writablecomparable<indexerkey> { public static class groupcomparator extends writablecomparator implements serializable { private static final long serialversionuid = -3385728040072507941l; public groupcomparator() { super(customkey .class, true); } @suppresswarnings("rawtypes") public int compare(writablecomparable a, writablecomparable b) { customkey w1 = (customkey ) a; customkey w2 = (customkey ) b; return w1.comparegroup(w2); } } } hope you.
Comments
Post a Comment