Package org.apache.beam.sdk.util
Class PythonCallableSource
- java.lang.Object
-
- org.apache.beam.sdk.util.PythonCallableSource
-
- All Implemented Interfaces:
java.io.Serializable
public class PythonCallableSource extends java.lang.Object implements java.io.Serializable
A wrapper object storing a Python function definition that can be evaluated to Python callables in Python SDK.The snippet of Python code can be a valid Python expression (such as
lambda x: x * x
or {str.upper}), a fully qualified name (such asmath.sin
), or a complete, multi-line function or class definition (such asdef foo(x): ...
orclass Foo: ...
).Any lines preceding the function definition are first evaluated to provide context in which to define the function which can be useful to declare imports or any other needed values, e.g.
import math def helper(x): return x * x def func(y): return helper(y) + y
in which casefunc
would get applied to each element.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getPythonCallableCode()
static PythonCallableSource
of(java.lang.String pythonCallableCode)
-
-
-
Method Detail
-
of
public static PythonCallableSource of(java.lang.String pythonCallableCode)
-
getPythonCallableCode
public java.lang.String getPythonCallableCode()
-
-