@PublicEvolving public class FunctionContext extends Object
FunctionContext allows to obtain global runtime information about the context in which
the user-defined function is executed.
The information includes the metric group, distributed cache files, and global job parameters.
Note: Depending on the call location of a function, not all information might be available. For example, during constant expression reduction the function is executed locally with minimal information.
| Constructor and Description |
|---|
FunctionContext(org.apache.flink.api.common.functions.RuntimeContext context) |
FunctionContext(org.apache.flink.api.common.functions.RuntimeContext context,
ClassLoader userClassLoader,
org.apache.flink.configuration.Configuration jobParameters) |
| Modifier and Type | Method and Description |
|---|---|
File |
getCachedFile(String name)
Gets the local temporary file copy of a distributed cache files.
|
Set<org.apache.flink.api.common.externalresource.ExternalResourceInfo> |
getExternalResourceInfos(String resourceName)
Get the external resource information.
|
String |
getJobParameter(String key,
String defaultValue)
Gets the global job parameter value associated with the given key as a string.
|
org.apache.flink.metrics.MetricGroup |
getMetricGroup()
Returns the metric group for this parallel subtask.
|
ClassLoader |
getUserCodeClassLoader()
Gets the
ClassLoader to load classes that are not in system's classpath, but are part
of the JAR file of a user job. |
public FunctionContext(@Nullable org.apache.flink.api.common.functions.RuntimeContext context, @Nullable ClassLoader userClassLoader, @Nullable org.apache.flink.configuration.Configuration jobParameters)
public FunctionContext(org.apache.flink.api.common.functions.RuntimeContext context)
public org.apache.flink.metrics.MetricGroup getMetricGroup()
public File getCachedFile(String name)
name - distributed cache file namepublic String getJobParameter(String key, String defaultValue)
key - key pointing to the associated valuedefaultValue - default value which is returned in case global job parameter is null or
there is no value associated with the given keypublic Set<org.apache.flink.api.common.externalresource.ExternalResourceInfo> getExternalResourceInfos(String resourceName)
public ClassLoader getUserCodeClassLoader()
ClassLoader to load classes that are not in system's classpath, but are part
of the JAR file of a user job.Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.