You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Dmitriy Setrakyan <ds...@apache.org> on 2015/03/04 02:41:22 UTC
Counting characters example in Ignite in Java8
Collection<String> words = Arrays.asList("How Many Characters".split(" "));
// Each closure is given a single word and returns the word's length.
// Each closure will be executed on a different cluster member.
Collection<Integer> res = ignite.compute().apply(String::length, words);
int sum = res.stream().mapToInt(Integer::intValue).sum();
Re: Counting characters example in Ignite in Java8
Posted by Dmitriy Setrakyan <ds...@apache.org>.
Here is the full version:
--------
try (Ignite ignite = Ignition.start()) {
Collection<String> words = Arrays.asList("How Many Characters".split("
"));
// Each closure is given a single word and returns the word's length.
// Each closure will be executed on a different cluster member.
Collection<Integer> res = ignite.compute().apply(String::length, words);
int sum = res.stream().mapToInt(Integer::intValue).sum();
System.out.println("Total number of characters is '" + sum + "'.");
}
----------
On Tue, Mar 3, 2015 at 5:41 PM, Dmitriy Setrakyan <ds...@apache.org>
wrote:
> Collection<String> words = Arrays.asList("How Many Characters".split(" "));
>
> // Each closure is given a single word and returns the word's length.
> // Each closure will be executed on a different cluster member.
> Collection<Integer> res = ignite.compute().apply(String::length, words);
>
> int sum = res.stream().mapToInt(Integer::intValue).sum();
>