public class PartitionedParallelRegexGrep
extends java.lang.Object
PartitionedParallelRegexGrep is like ParallelRegexGrep, except that the Java
object in the tuple being passed into the parallel region implements the
Keyable interface, and provides a getKey() function which is used to map
tuples to their corresponding channel in the parallel region.
Each channel of the parallel region only receives tuples that have the same
hashCode() value of the Key returned by the tuple value's getKey() method. In
other words, for each tuple, the value returned by
tupleValue.getKey().hashCode()
will go to the same channel, for each tuple which returns that result. To
show this, instead of passing a java.lang.String into the parallel region, a
stringWrapper class is created that implements the Keyable interface.
For this sample, if you read from a file that contains the following:
Apple Orange Banana Banana Apple Apple
you notice that the lines containing Apple will always be sent to the same
channel of the parallel region; the same for the lines containing Orange and
Banana.