You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by "Colletta, Edward" <Ed...@FMR.COM> on 2021/03/11 11:08:27 UTC

uniqueness of name when constructing a StateDescriptor

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

RE: uniqueness of name when constructing a StateDescriptor

Posted by "Colletta, Edward" <Ed...@FMR.COM>.
Thank you.   

-----Original Message-----
From: Tzu-Li (Gordon) Tai <tz...@apache.org> 
Sent: Monday, March 15, 2021 3:05 AM
To: user@flink.apache.org
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/

Re: uniqueness of name when constructing a StateDescriptor

Posted by "Tzu-Li (Gordon) Tai" <tz...@apache.org>.
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/