Re: Passing parameters to filter function (in DataStreams)
Your original post looks like "computeThreshold" doesn't require any parameters, but is just an expensive to compute operation.
In that case, you can inherit from "RichFilterFunction" instead of "FilterFunction". In case of "RichFilterFunction", you can override the "open"-method and perform your operation in there just once and store the result e.g. in a transient variable. In that case, nothing gets serialized and send over the network. The open method is guaranteed to be called only once per operator and is called before the first call to "filter" is made.
The pattern to pass arguments in general is totally fine. I often pass e.g. a connection String as a parameter to my RichFunction and within the open method of the function, I establish the connection to some remote system.
Von: "Komal Mariam" <[hidden email]> An: "Chesnay Schepler" <[hidden email]> CC: "user" <[hidden email]> Gesendet: Donnerstag, 10. Oktober 2019 04:00:46 Betreff: Re: Passing parameters to filter function (in DataStreams)
Thank you @Chesnay!
I also managed to pass arguments to a RichFilterFunction:
new MyFilterFunc(Integer threshold) by defining its constructor.
If there's a better way to pass arguments I'd appreciate it if you let me know.