IN - Type of objects to extract the key from.KEY - Type of key.public interface KeySelector<IN,KEY> extends org.apache.flink.api.common.functions.Function, Serializable
KeySelector allows to use arbitrary objects for operations such as
reduce, reduceGroup, join, coGoup, etc.
The extractor takes an object and returns the key for that object.| Modifier and Type | Method and Description |
|---|---|
KEY |
getKey(IN value)
User-defined function that extracts the key from an arbitrary object.
|
KEY getKey(IN value) throws Exception
public class Word {
String word;
int count;
}
The key extractor could return the word as
a key to group all Word objects by the String they contain.
The code would look like this
public String getKey(Word w) {
return w.word;
}
value - The object to get the key from.Exception - Throwing an exception will cause the execution of the respective task to fail,
and trigger recovery or cancellation of the program.Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.