Class KeySelectorUtil.OneKeySelector<IN,K>
- java.lang.Object
-
- org.apache.flink.streaming.util.keys.KeySelectorUtil.OneKeySelector<IN,K>
-
- Type Parameters:
IN
- The type of the elements where the key is extracted from.K
- The type of the key.
- All Implemented Interfaces:
Serializable
,Function
,KeySelector<IN,K>
- Enclosing class:
- KeySelectorUtil
public static final class KeySelectorUtil.OneKeySelector<IN,K> extends Object implements KeySelector<IN,K>
Key extractor that extracts a single field via a generic comparator.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description K
getKey(IN value)
User-defined function that deterministically extracts the key from an object.
-
-
-
Method Detail
-
getKey
public K getKey(IN value) throws Exception
Description copied from interface:KeySelector
User-defined function that deterministically extracts the key from an object.For example for a class:
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; }
- Specified by:
getKey
in interfaceKeySelector<IN,K>
- Parameters:
value
- The object to get the key from.- Returns:
- The extracted key.
- Throws:
Exception
- Throwing an exception will cause the execution of the respective task to fail, and trigger recovery or cancellation of the program.
-
-