java - 从 Flink 中的 ProcessWindowFunction 的上下文中获取 Collector 对象
问题描述
我在 ProcessWindowFunction 的clear步骤中模仿 TTL 缓存失效,并尝试以 clear 方法访问进程中使用的收集器对象。是否可以使用Context或getRuntimeContext获得它。
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);
}
}
解决方案
推荐阅读
- ios - SceneKit UIImage 材质为黑色
- node.js - 如何将 pdf 文件从 node/express 应用程序发送到 Flutter 应用程序?
- unity3d - 在 Unity 2D 中设置最大水平移动速度而不设置最大速度
- javascript - 如何为 D3 图表启用静态链接
- python - 如何使用 Skimage 调整训练数据的大小?
- c# - 创建 3D 阵列意见系统
- list - Haskell:如何创建一个空列表作为数据类型的选项?
- javascript - 在 SVG 路径中移动到鼠标单击 (d3.js)
- deep-learning - 推理时间短的分类模型
- php - 如何进行批量操作以将文件复制到谷歌驱动器,php?