[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getRuntimeContext(): The runtime context has not been initialized.

Yes, it would be good to post your code.
Are you using a FoldFunction in a window (if yes, what window) or as a running aggregate?

In general, collecting state in a FoldFunction is usually not something that you should do. Did you consider using an AggregateFunction?


Am Mi., 10. Okt. 2018 um 11:08 Uhr schrieb Chesnay Schepler <chesnay@xxxxxxxxxx>:
In which method are you calling getRuntimeContext()? This method can only be used after open() has been called.

On 09.10.2018 17:09, Ahmad Hassan wrote:

We want to use MapState inside fold function to keep the map of all products that we see in 24 hour window to store huge state in rocksdb rather than overflowing heap. However, I don't seem to initialise mapstate within foldfunction or any class that is extending RichMapFunction

private transient MapStateDescriptor<String, String> descr = new MapStateDescriptor<>("mymap", String.class, String.class);

I get error

java.lang.IllegalStateException: The runtime context has not been initialized.
at org.apache.flink.api.common.functions.AbstractRichFunction.getRuntimeContext(AbstractRichFunction.java:53)

Any clues how to get the runtime context please?


Best regards