My incoming event contains userId property. I'd like to be able to read the parameter value according to userId from the CQEngine. Should I implement this as extension of FunctionExecutor and use it like:
define stream cseEventStream (userId string, symbol string, price long, volume long);
@info(name = 'query1')
from cseEventStream [price < custom:cache(userId)]
select *
insert into Output
or is there some better way how to do it. The problem is that before first use of CQEngine I need to initialize it with data. Probably "start" method of the FunctionExecutor could be used for this purpose?
You can go ahead with a FunctionExecutor
and implement initialization logic within either init()
or start()
. Both will be called once per function usage. Calling order is init()
followed by start()
. However, as per API doc, it's advised to use start()
to acquire required resources for the processing element. and stop()
to release acquired resources.