Regarding Keyed State of Connected Stream

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

Regarding Keyed State of Connected Stream

Garvit Sharma
Hi,

Let's consider, I have two keyed streams one for rules and another for data and I have created a connected stream.

I am maintaining a managed keyed state (ValueState), rules stream will keep updating the state and data stream will keep reading from it.

Do I need to take a lock explicitly while updating the state or not?

I need to understand. 

Please let me know.

Thanks,

--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.
Reply | Threaded
Open this post in threaded view
|

Re: Regarding Keyed State of Connected Stream

gerryzhou
Hi Garvit,

I think you don't need to lock it, they are executed in the same thread sync.

Best, Sihua





在2018年05月25日 10:26,[hidden email] 写道:
Hi,

Let's consider, I have two keyed streams one for rules and another for data and I have created a connected stream.

I am maintaining a managed keyed state (ValueState), rules stream will keep updating the state and data stream will keep reading from it.

Do I need to take a lock explicitly while updating the state or not?

I need to understand. 

Please let me know.

Thanks,

--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.
Reply | Threaded
Open this post in threaded view
|

Re: Regarding Keyed State of Connected Stream

Garvit Sharma
Hi Sihua,

Thanks for the quick response. 

Could you please let me know, where can I find more details about it.


Thanks,

On Fri, May 25, 2018 at 11:04 AM, sihua zhou <[hidden email]> wrote:
Hi Garvit,

I think you don't need to lock it, they are executed in the same thread sync.

Best, Sihua






在2018年05月25日 10:26,[hidden email] 写道:
Hi,

Let's consider, I have two keyed streams one for rules and another for data and I have created a connected stream.

I am maintaining a managed keyed state (ValueState), rules stream will keep updating the state and data stream will keep reading from it.

Do I need to take a lock explicitly while updating the state or not?

I need to understand. 

Please let me know.

Thanks,

--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.



--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.
Reply | Threaded
Open this post in threaded view
|

Re: Regarding Keyed State of Connected Stream

gerryzhou
Hi Garvit,

If you don't mind to take a look at the source code, I would suggest you to have a look at the "StreamTwoInputProcessor#processInput()" in StreamTwoInputProcessor.java. Your customer function will be called via here, the "CoFlatMapFunction#flatMap1()" will be called via streamOperator.processElement1(record);", "CoFlatMapFunction#flatMap2()" will be called via streamOperator.processElement2(record);". You could follow the calling chain to find more detail if you want.

Best, Sihua



On 05/25/2018 14:05[hidden email] wrote:
Hi Sihua,

Thanks for the quick response. 

Could you please let me know, where can I find more details about it.


Thanks,

On Fri, May 25, 2018 at 11:04 AM, sihua zhou <[hidden email]> wrote:
Hi Garvit,

I think you don't need to lock it, they are executed in the same thread sync.

Best, Sihua






在2018年05月25日 10:26,[hidden email] 写道:
Hi,

Let's consider, I have two keyed streams one for rules and another for data and I have created a connected stream.

I am maintaining a managed keyed state (ValueState), rules stream will keep updating the state and data stream will keep reading from it.

Do I need to take a lock explicitly while updating the state or not?

I need to understand. 

Please let me know.

Thanks,

--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.



--

Garvit Sharma
github.com/garvitlnmiit/

No Body is a Scholar by birth, its only hard work and strong determination that makes him master.