Pavel Jezek
10/10/2023, 12:36 PMMapState in PyFlink and have the following code:
...
class DelaySumFunction(KeyedProcessFunction):
def __init__(self):
self.map_state = None
def open(self, runtime_context):
state_ttl_config = (
StateTtlConfig.new_builder(Time.minutes(5))
.set_state_visibility(StateTtlConfig.StateVisibility.NeverReturnExpired)
.build()
)
state_descriptor = MapStateDescriptor("delays", <http://Types.INT|Types.INT>(), <http://Types.INT|Types.INT>())
state_descriptor.enable_time_to_live(state_ttl_config)
self.map_state = runtime_context.get_state(state_descriptor)
def process_element(self, value, ctx: "ProcessFunction.Context"):
self.map_state.put(value[0], value[1])
yield Row(self.map_state.values().sum())
...
When I run pipeline with this process function I get the following exception and cannot figure it out
File "/opt/flink/usrlib/prague-sum-delays.py", line 31, in process_element
self.map_state.put(value[0], value[1])
AttributeError: 'SynchronousValueRuntimeState' object has no attribute 'put'
Anyone have any pointers?Siddhesh Kalgaonkar
10/11/2023, 7:38 AMPavel Jezek
10/11/2023, 8:35 AM