@Internal public class KeyByKeySelector extends Object implements KeySelector<Row,Object>
KeyByKeySelector
is responsible for extracting the first field of the input row as key.
The input row is generated by python DataStream map function in the format of
(key_selector.get_key(value), value) tuple2.Constructor and Description |
---|
KeyByKeySelector(boolean isKeyPickledByteArray) |
Modifier and Type | Method and Description |
---|---|
Object |
getKey(Row value)
User-defined function that deterministically extracts the key from an object.
|
public Object getKey(Row value) throws Exception
KeySelector
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; }
getKey
in interface KeySelector<Row,Object>
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–2021 The Apache Software Foundation. All rights reserved.