hadoop - Send ordered keys to correct reducer -
hadoop - Send ordered keys to correct reducer -
if have keys 0 19, , want create partitioner send records keys 0 , 1 first reducer, 2 , 3 sec reducer , on. there way of doing this?
in cases, you need know number of reducers before hand. solution quite generic per level of understanding question,
looking @ question, next sequence occurs,
reducer0 keys 0,1|reducer1 keys 2,3|reducer2 keys 4,5|reducer3 keys 6,7| reducer4 keys 8,9|reducer5 keys 10,11|reducer6 keys 12,13|reducer7 keys 14,15| reducer8 keys 16,17|reducer9 keys 18,19
in case, integer value of key in partitioner
set reducer key/2
if key 13, reducer 13/2 = 6 if key 14, reducer 14/2 = 7
public static class custompartitioner extends partitioner<intwritable, whatever> { @override public int getpartition(intwritable key, whatever value, int numreducetasks) { int keyasinteger = key.get(); homecoming keyasinteger/2; } }
hadoop
Comments
Post a Comment