org.redisson.api.mapreduce.RMapReduce Java Examples
The following examples show how to use
org.redisson.api.mapreduce.RMapReduce.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedissonMapReduceTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testCancel() throws InterruptedException, ExecutionException { RMap<String, String> map = getMap(); for (int i = 0; i < 100000; i++) { map.put("" + i, "ab cd fjks"); } RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce().mapper(new WordMapper()).reducer(new WordReducer()); RFuture<Map<String, Integer>> future = mapReduce.executeAsync(); Thread.sleep(100); future.cancel(true); }
Example #2
Source File: RedissonMapReduceTest.java From redisson with Apache License 2.0 | 5 votes |
@Test(expected = MapReduceTimeoutException.class) public void testTimeout() { RMap<String, String> map = getMap(); for (int i = 0; i < 100000; i++) { map.put("" + i, "ab cd fjks"); } RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce() .mapper(new WordMapper()) .reducer(new WordReducer()) .timeout(1, TimeUnit.SECONDS); mapReduce.execute(); }
Example #3
Source File: RedissonMapReduceTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testCollatorTimeout() { RMap<String, String> map = getMap(); map.put("1", "Alice was beginning to get very tired"); RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce() .mapper(new WordMapperInject()) .reducer(new WordReducerInject()) .timeout(10, TimeUnit.SECONDS); Integer res = mapReduce.execute(new WordCollatorInject()); assertThat(res).isEqualTo(7); }
Example #4
Source File: RedissonMapReduceTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testInjector() { RMap<String, String> map = getMap(); map.put("1", "Alice was beginning to get very tired"); RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce().mapper(new WordMapperInject()).reducer(new WordReducerInject()); mapReduce.execute(); assertThat(redisson.getAtomicLong("test").get()).isEqualTo(8); mapReduce.execute(new WordCollatorInject()); assertThat(redisson.getAtomicLong("test").get()).isEqualTo(16 + 1); }
Example #5
Source File: TracingRMapReduce.java From java-redis-client with Apache License 2.0 | 4 votes |
public TracingRMapReduce(RMapReduce<KIn, VIn, KOut, VOut> mapReduce, TracingRedissonHelper tracingRedissonHelper) { super(mapReduce, tracingRedissonHelper); this.mapReduce = mapReduce; this.tracingRedissonHelper = tracingRedissonHelper; }
Example #6
Source File: TracingRMap.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce() { return new TracingRMapReduce<>(map.mapReduce(), tracingRedissonHelper); }
Example #7
Source File: MapReduceExample.java From redisson-examples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); redisson.getExecutorService(RExecutorService.MAPREDUCE_NAME).registerWorkers(WorkerOptions.defaults().workers(3)); RMap<String, String> map = redisson.getMap("myMap"); map.put("1", "Alice was beginning to get very tired"); map.put("2", "of sitting by her sister on the bank and"); map.put("3", "of having nothing to do once or twice she"); map.put("4", "had peeped into the book her sister was reading"); map.put("5", "but it had no pictures or conversations in it"); map.put("6", "and what is the use of a book"); map.put("7", "thought Alice without pictures or conversation"); Map<String, Integer> result = new HashMap<>(); result.put("to", 2); result.put("Alice", 2); result.put("get", 1); result.put("beginning", 1); result.put("sitting", 1); result.put("do", 1); result.put("by", 1); result.put("or", 3); result.put("into", 1); result.put("sister", 2); result.put("on", 1); result.put("a", 1); result.put("without", 1); result.put("and", 2); result.put("once", 1); result.put("twice", 1); result.put("she", 1); result.put("had", 2); result.put("reading", 1); result.put("but", 1); result.put("it", 2); result.put("no", 1); result.put("in", 1); result.put("what", 1); result.put("use", 1); result.put("thought", 1); result.put("conversation", 1); result.put("was", 2); result.put("very", 1); result.put("tired", 1); result.put("of", 3); result.put("her", 2); result.put("the", 3); result.put("bank", 1); result.put("having", 1); result.put("nothing", 1); result.put("peeped", 1); result.put("book", 2); result.put("pictures", 2); result.put("conversations", 1); result.put("is", 1); RMapReduce<String, String, String, Integer> mapReduce = map .<String, Integer>mapReduce() .mapper(new WordMapper()) .reducer(new WordReducer()); Integer count = mapReduce.execute(new WordCollator()); System.out.println("Count " + count); Map<String, Integer> resultMap = mapReduce.execute(); System.out.println("Result " + resultMap); }
Example #8
Source File: RedissonTransactionalMapCache.java From redisson with Apache License 2.0 | 4 votes |
@Override public <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce() { throw new UnsupportedOperationException("mapReduce method is not supported in transaction"); }
Example #9
Source File: RedissonTransactionalMap.java From redisson with Apache License 2.0 | 4 votes |
@Override public <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce() { throw new UnsupportedOperationException("mapReduce method is not supported in transaction"); }
Example #10
Source File: RedissonMap.java From redisson with Apache License 2.0 | 4 votes |
@Override public <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce() { return new RedissonMapReduce<>(this, redisson, commandExecutor.getConnectionManager()); }
Example #11
Source File: RedissonMapReduceTest.java From redisson with Apache License 2.0 | 4 votes |
@Test public void test() { RMap<String, String> map = getMap(); map.put("1", "Alice was beginning to get very tired"); map.put("2", "of sitting by her sister on the bank and"); map.put("3", "of having nothing to do once or twice she"); map.put("4", "had peeped into the book her sister was reading"); map.put("5", "but it had no pictures or conversations in it"); map.put("6", "and what is the use of a book"); map.put("7", "thought Alice without pictures or conversation"); Map<String, Integer> result = new HashMap<>(); result.put("to", 2); result.put("Alice", 2); result.put("get", 1); result.put("beginning", 1); result.put("sitting", 1); result.put("do", 1); result.put("by", 1); result.put("or", 3); result.put("into", 1); result.put("sister", 2); result.put("on", 1); result.put("a", 1); result.put("without", 1); result.put("and", 2); result.put("once", 1); result.put("twice", 1); result.put("she", 1); result.put("had", 2); result.put("reading", 1); result.put("but", 1); result.put("it", 2); result.put("no", 1); result.put("in", 1); result.put("what", 1); result.put("use", 1); result.put("thought", 1); result.put("conversation", 1); result.put("was", 2); result.put("very", 1); result.put("tired", 1); result.put("of", 3); result.put("her", 2); result.put("the", 3); result.put("bank", 1); result.put("having", 1); result.put("nothing", 1); result.put("peeped", 1); result.put("book", 2); result.put("pictures", 2); result.put("conversations", 1); result.put("is", 1); RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce().mapper(new WordMapper()).reducer(new WordReducer()); assertThat(mapReduce.execute()).isEqualTo(result); Integer count = mapReduce.execute(new WordCollator()); assertThat(count).isEqualTo(57); mapReduce.execute("resultMap"); RMap<Object, Object> resultMap = redisson.getMap("resultMap"); assertThat(resultMap).isEqualTo(result); resultMap.delete(); }
Example #12
Source File: RMap.java From redisson with Apache License 2.0 | 2 votes |
/** * Returns <code>RMapReduce</code> object associated with this map * * @param <KOut> output key * @param <VOut> output value * @return MapReduce instance */ <KOut, VOut> RMapReduce<K, V, KOut, VOut> mapReduce();