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

Viewed 725

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

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)
1 Answers
Related