Class FunctionContext


  • @PublicEvolving
    public class FunctionContext
    extends Object
    A 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 Detail

      • FunctionContext

        public FunctionContext​(@Nullable
                               org.apache.flink.api.common.functions.RuntimeContext context,
                               @Nullable
                               ClassLoader userClassLoader,
                               @Nullable
                               org.apache.flink.api.common.functions.OpenContext openContext)
      • FunctionContext

        public FunctionContext​(org.apache.flink.api.common.functions.RuntimeContext context)
    • Method Detail

      • getMetricGroup

        public org.apache.flink.metrics.MetricGroup getMetricGroup()
        Returns the metric group for this parallel subtask.
        Returns:
        metric group for this parallel subtask.
      • getCachedFile

        public File getCachedFile​(String name)
        Gets the local temporary file copy of a distributed cache files.
        Parameters:
        name - distributed cache file name
        Returns:
        local temporary file copy of a distributed cache file.
      • getJobParameter

        public String getJobParameter​(String key,
                                      String defaultValue)
        Gets the global job parameter value associated with the given key as a string.
        Parameters:
        key - key pointing to the associated value
        defaultValue - default value which is returned in case global job parameter is null or there is no value associated with the given key
        Returns:
        (default) value associated with the given key
      • getExternalResourceInfos

        public Set<org.apache.flink.api.common.externalresource.ExternalResourceInfo> getExternalResourceInfos​(String resourceName)
        Get the external resource information.
      • getUserCodeClassLoader

        public 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.