Hi,

I think what you are doing makes sense in principal. Probably you don't
want to store all the data until you have enough but compute only what's
necessary on the fly. So e.g. for your example I would store only how
many consecutive events with temperature higher than 10 you have seen so
far.

If you need access to timers you can also have a look at the
KeyedProcessFunction[1] instead of FlatMap function. E.g. if you want to
find only 10 consecutive events with temperature higher than 10 that
happened within one hour.

Best,

Dawid

[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.10/dev/stream/operators/process_function.html#process-function-low-level-operations

On 25/03/2020 02:41, yang xu wrote:
> Hi Dawid
> I use Flink to calculate IOT device alarms,My scenario is that each device
> has an independent alarm strategy,For example, I calculate that the
> temperature of 10 consecutive event data of a device is higher than 10
> degrees。
> I use: 
> sourceStream.keyBy("deviceNo")
>                 .flatMap(new StateAlarmCalculationFunction()).....
> StateAlarmCalculationFunction extends RichFlatMapFunction 
> StateAlarmCalculationFunction  use ListState<DeviceState> deviceListState to
> store the device state. After each device data comes in, I load the
> deviceListState for calculation,But I don't think it's smart enough. Is
> there anything better
>
>
>
> --
> Sent from: 
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to