public class PythonKeySelector extends Object implements KeySelector<org.python.core.PyObject,PyKey>
PythonKeySelector
is a thin wrapper layer over a Python UDF KeySelector
.
It receives a KeySelector
as an input and keeps it internally in a serialized form.
It is then delivered, as part of the job graph, up to the TaskManager, then it is opened and becomes
a sort of mediator to the Python UDF KeySelector
.
This function is used internally by the Python thin wrapper layer over the streaming data functionality
Constructor and Description |
---|
PythonKeySelector(KeySelector<org.python.core.PyObject,PyKey> fun) |
Modifier and Type | Method and Description |
---|---|
PyKey |
getKey(org.python.core.PyObject value)
User-defined function that deterministically extracts the key from an object.
|
public PythonKeySelector(KeySelector<org.python.core.PyObject,PyKey> fun) throws IOException
IOException
public PyKey getKey(org.python.core.PyObject 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<org.python.core.PyObject,PyKey>
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–2020 The Apache Software Foundation. All rights reserved.