uniqueness of name when constructing a StateDescriptor

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

uniqueness of name when constructing a StateDescriptor

Colletta, Edward

The documentation for ValueStateDescriptor documents the name parameter as - “name - The (unique) name for the state."

What is the scope of the uniqueness?  Unique within an RichFunction instance? Unique withing job? Unique within a session cluster?

 

I ask because I have several jobs that use a KeyedProcessFunction or RIchFlatMapFunction in a loop.   Something like

   for (int t:cfg.intervals)

                stream

                                .process(new FuncA(t))

                                .flatMap(new FuncB())

 

Where FuncA has something like the following in its open method.

     state = getRuntimeContext().getState(new ValueStateDescriptor<>("funcAState", stateTypeInfo, null));

 

The code seems to work fine, but I am wondering If I need to pass something in the constructor to make the state name unique for each instance created in the loop.

 

Thanks,

Eddie Colletta

Reply | Threaded
Open this post in threaded view
|

Re: uniqueness of name when constructing a StateDescriptor

Tzu-Li (Gordon) Tai
Hi,

The scope is per individual operator, i.e. a single KeyedProcessFunction
instance cannot have multiple registered state with the same name.

Cheers,
Gordon



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

RE: uniqueness of name when constructing a StateDescriptor

Colletta, Edward
Thank you.  

-----Original Message-----
From: Tzu-Li (Gordon) Tai <[hidden email]>
Sent: Monday, March 15, 2021 3:05 AM
To: [hidden email]
Subject: Re: uniqueness of name when constructing a StateDescriptor

NOTICE: This email is from an external sender - do not click on links or attachments unless you recognize the sender and know the content is safe.


Hi,

The scope is per individual operator, i.e. a single KeyedProcessFunction instance cannot have multiple registered state with the same name.

Cheers,
Gordon



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/