Apache 从Flink中ProcessWindowFunction的上下文获取收集器对象
我在ProcessWindowFunction的clear步骤中模拟TTL缓存失效,并尝试以clear方法访问进程中使用的收集器对象。是否可以使用上下文或getRuntimeContext获取它Apache 从Flink中ProcessWindowFunction的上下文获取收集器对象,apache,streaming,apache-flink,Apache,Streaming,Apache Flink,我在ProcessWindowFunction的clear步骤中模拟TTL缓存失效,并尝试以clear方法访问进程中使用的收集器对象。是否可以使用上下文或getRuntimeContext获取它 public class TimedProcess extends ProcessWindowFunction<Map<String, List<String>>, Map<String, List<String>>, String , TimeWi
public class TimedProcess extends ProcessWindowFunction<Map<String, List<String>>, Map<String, List<String>>, String , TimeWindow> {
Map<String, List<String>> cachedValue;
@Override
public void clear(Context context) throws Exception {
// How to get output used in process function here
// Collector<Map<String, List<String>>> output = ?
// Map<String, List<String> recentCacheValue;
// output.collect(recentCacheValue)
}
@Override
public void process(String visitorId, Context context, Iterable<Map<String, List<String>>> input, Collector<Map<String, List<String>>> output) throws Exception {
// cache store logic
// output.collect(cachedValue);
}
}
公共类TimedProcess扩展ProcessWindowFunction{
映射缓存值;
@凌驾
public void clear(上下文)引发异常{
//如何在这里获取过程函数中使用的输出
//收集器输出=?
//MapI我很确定这不会起作用。这看起来真的很奇怪。我们可以后退一步,检查一下您首先要实现的是什么吗?为什么它需要在清除?返回并重新检查了其他选项,发现对于那个用例,正确的实现方法是使用处理函数,这让我有了定时器
控制触发器动作的方法。