简体   繁体   English

如何在 flink stream 处理中使用过滤器在键控 stream 上添加进程 function?

[英]How to add process function on a keyed stream with filters in flink stream processing?

I've a data stream, which I'm keying by a field, on which, I'm adding a RichFilter to filter out data which's not suitable, while using flink state.我有一个数据 stream,我通过一个字段键入它,在该字段上,我添加了一个 RichFilter 来过滤掉不合适的数据,同时使用 flink state。 I want to process this filtered out data with a keyed process function as I want to make use of the flink valueState in this process function.我想用一个键控进程 function 处理这个过滤掉的数据,因为我想在这个进程 function 中使用 flink valueState。 But since the output of filter isn't a keyed stream, I'm not able to chain it with keyed process function, unless I key it again by the same field.但是由于过滤器的 output 不是键控 stream,因此我无法将其与键控进程 function 链接,除非我再次通过相同的字段对其进行键控。

Right now, this's working, but is there a simpler way to do this, rather than keying it twice?现在,这是可行的,但是有没有更简单的方法来做到这一点,而不是键入两次?

DataStream stream = some stream data
stream.keyBy(myKeySelector).filter(RichFilterFunction).keyBy(myKeySelector).process(KeyedProcessFunction)

Seems like a job for reinterpretAsKeyedStream .似乎是reinterpretAsKeyedStream的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM