Hi,
I want to get the last value stored in ValueState when processing element in Trigger.
But as the log shows that sometimes I can get the value, sometimes not.
Only one key in my data(SensorReading).
ValueState:
class ProcessingTimeTrigger extends Trigger[SensorReading, TimeWindow] { var value = 1
override def onElement( r: SensorReading, timestamp: Long, window: TimeWindow, ctx: Trigger.TriggerContext): TriggerResult = { Main process:
object MyCustomWindows { Log results:
Best regards
Utopia
|
Hi Utopia, The behavior may be correct. First, the default value is null. It's the correct value. `ValueStateDescriptor` has multiple constructors, some of them can let you specify a default value. However, these constructors are deprecated. And the doc does not recommend them.[1] For the other constructors which can not specify default values, it would be null. Second, before the window, there is a `keyBy` operation. it will partition your data. For each partition, the default value state is null. Best, Vino Utopia <[hidden email]> 于2019年12月18日周三 下午7:20写道:
|
Hi Vino,
Thanks for your reply !
The key of my input data is same value. So I think there is only one partition.
And Why sometimes I can get the value stored in the ValueState before update?
What’s more, How can I stored the previous value so that I can get the value when next element come in and invoke the onElement method?
Best regards
Utopia
在 2019年12月18日 +0800 21:57,vino yang <[hidden email]>,写道:
|
Hi Vino,
Maybe it is due to the type of window. What I used is ProcessingTimeSessionWindows, while keyedState is scoped to window and key. Window changes so that the ValueState is different.
Best regards
Utopia
在 2019年12月18日 +0800 22:30,Utopia <[hidden email]>,写道:
|
Hi Utopia, IMO, your analysis is correct. Best, Vino Utopia <[hidden email]> 于2019年12月19日周四 上午12:44写道:
|
Free forum by Nabble | Edit this page |