Search code examples
apache-flink

Current key in ProcessWindowFunction


Seems like I'm missing something obvious but there doesn't appear to be a way to get the current key from the Context object in the ProcessWindowFunction::process method? This class extends AbstractRichFunction and not KeyedProcessFunction, however it requires a key in it's template specification and can only operate on keyed streams (vs the ProcessAllWindowFunction).

In my case I can get the key from the input events themselves - is there an alternative in the style of Keyed*Functions?


Solution

  • The current key is passed as the first parameter to the process method:

    public abstract void process(
       KEY key, Context context, Iterable<IN> elements, Collector<OUT> out) throws Exception;