
Let's take search for example. You can model almost any search as taking a collection of values, picking the right value in that collection, and returning that value. For example, let's assume that we need to find the max value in a collection (forgive the simplicity of the example, in real life you would probably be grid-enabling searches that are a lot more complex than this one).
In Java this would look like the following:
If we were to grid-enable above functionality, we would have to do the following:
public Integer findMax(Collection<Integer> vals) {
Integer max = Collections.max(vals);
return max;
}
- Map Step: Split the initial collection into a number of sub-collections
- Send each sub-collection to a remote node
- Have every remote node find a max value in the sub-collection assigned to it and return it.
- Reduce Step: Find the maximum out of all values returned from remote nodes and return it to user.
To do this search in GridGain 3.0, all you would have to do is attach @GridifySetToValue(recursive=true) annotation to your method and you are done:
By a virtue of attaching a single annotation, you are basically telling GridGain to perform steps 1 to 4 described above automatically. On top of that, with GridGain peer-class-loading functionality no code needs to be explicitly deployed to remote nodes at all. Simply bring up several GridGain images on a cloud and they are ready to start computing whatever you throw at them.
@GridifySetToValue(recursive=true)
public Integer findMax(Collection<Integer> vals) {
Integer max = Collections.max(vals);
return max;
}
In the coming weeks I will show how some other annotations can be used to automate grid-enabling of other common tasks we encounter on daily basis.
I should also mention that you can achieve the above with relative ease on the current version of GridGain (you would have to do some of the steps manually though).
Stay tuned for GridGain 3.0 scheduled for release this summer.
View comments