Interface KeySelector<IN,KEY>
-
- Type Parameters:
IN
- Type of objects to extract the key from.KEY
- Type of key.
- All Superinterfaces:
Function
,Serializable
- All Known Subinterfaces:
RowDataKeySelector
- All Known Implementing Classes:
BinaryRowDataKeySelector
,EmptyRowDataKeySelector
,GenericRowDataKeySelector
,KeyByKeySelector
,KeySelectorUtil.ArrayKeySelector
,KeySelectorUtil.ComparableKeySelector
,KeySelectorUtil.OneKeySelector
,NullByteKeySelector
,PartitionCustomKeySelector
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@Public @FunctionalInterface public interface KeySelector<IN,KEY> extends Function, Serializable
TheKeySelector
allows to use deterministic objects for operations such as reduce, reduceGroup, join, coGroup, etc. If invoked multiple times on the same object, the returned key must be the same.The extractor takes an object and returns the deterministic key for that object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description KEY
getKey(IN value)
User-defined function that deterministically extracts the key from an object.
-
-
-
Method Detail
-
getKey
KEY getKey(IN value) throws Exception
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; }
- 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.
-
-