KIn
- input keyVIn
- input valueKOut
- output keyVOut
- output valuepublic interface RMapReduce<KIn,VIn,KOut,VOut> extends RMapReduceExecutor<VIn,KOut,VOut>
Usage example:
public class WordMapper implements RMapper<String, String, String, Integer> { public void map(String key, String value, RCollector<String, Integer> collector) { String[] words = value.split("[^a-zA-Z]"); for (String word : words) { collector.emit(word, 1); } } } public class WordReducer implements RReducer<String, Integer> { public Integer reduce(String reducedKey, Iterator<Integer> iter) { int sum = 0; while (iter.hasNext()) { Integer i = (Integer) iter.next(); sum += i; } return sum; } } public class WordCollator implements RCollator<String, Integer, Integer> { public Integer collate(Map<String, Integer> resultMap) { int result = 0; for (Integer count : resultMap.values()) { result += count; } return result; } } RMap<String, String> map = redisson.getMap("myWords"); Map<String, Integer> wordsCount = map.<String, Integer>mapReduce() .mapper(new WordMapper()) .reducer(new WordReducer()) .execute(); Integer totalCount = map.<String, Integer>mapReduce() .mapper(new WordMapper()) .reducer(new WordReducer()) .execute(new WordCollator());
Modifier and Type | Method and Description |
---|---|
RMapReduce<KIn,VIn,KOut,VOut> |
mapper(RMapper<KIn,VIn,KOut,VOut> mapper)
Setup Mapper object
|
RMapReduce<KIn,VIn,KOut,VOut> |
reducer(RReducer<KOut,VOut> reducer)
Setup Reducer object
|
RMapReduce<KIn,VIn,KOut,VOut> |
timeout(long timeout,
TimeUnit unit)
Defines timeout for MapReduce process.
|
execute, execute, execute, executeAsync, executeAsync, executeAsync
RMapReduce<KIn,VIn,KOut,VOut> timeout(long timeout, TimeUnit unit)
0
means infinity timeout.timeout
- for processunit
- of timeoutRMapReduce<KIn,VIn,KOut,VOut> mapper(RMapper<KIn,VIn,KOut,VOut> mapper)
mapper
- used during MapReduceCopyright © 2014–2019 The Redisson Project. All rights reserved.