How to access state from another map functions

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

How to access state from another map functions

Yuta Morisawa
Hi all

I want to use the same state for multiple times.

stream
.keyBy(0)
.map(new MyRichMapfunction)
...
.keyBy(0)
.map(new MyRichMapfunction2)


In this snippet, I want access the same state in MyRichMapfunction and
MyRichMapfunction2, but I failed in spite of keying the same key.
Is there any way to access the state from other class, or is there a
kind of global state.

--
Thank you.
Yuta

Reply | Threaded
Open this post in threaded view
|

Re: How to access state from another map functions

Biao Liu
Hi Yuta,

No, you can't get the same state from different functions. That's not the semantics of state. And these two functions might run in different threads/processes even on different machines. 

On Mon, Jul 29, 2019 at 11:12 AM Yuta Morisawa <[hidden email]> wrote:
Hi all

I want to use the same state for multiple times.

stream
.keyBy(0)
.map(new MyRichMapfunction)
...
.keyBy(0)
.map(new MyRichMapfunction2)


In this snippet, I want access the same state in MyRichMapfunction and
MyRichMapfunction2, but I failed in spite of keying the same key.
Is there any way to access the state from other class, or is there a
kind of global state.

--
Thank you.
Yuta

Reply | Threaded
Open this post in threaded view
|

Re: How to access state from another map functions

Yuta Morisawa
Hi Biao

Thank you for your reply.
I will consulting in-memory DB.


On 2019/07/29 14:52, Biao Liu wrote:

> Hi Yuta,
>
> No, you can't get the same state from different functions. That's not
> the semantics of state. And these two functions might run in different
> threads/processes even on different machines.
>
> On Mon, Jul 29, 2019 at 11:12 AM Yuta Morisawa
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi all
>
>     I want to use the same state for multiple times.
>
>     stream
>     .keyBy(0)
>     .map(new MyRichMapfunction)
>     ...
>     .keyBy(0)
>     .map(new MyRichMapfunction2)
>
>
>     In this snippet, I want access the same state in MyRichMapfunction and
>     MyRichMapfunction2, but I failed in spite of keying the same key.
>     Is there any way to access the state from other class, or is there a
>     kind of global state.
>
>     --
>     Thank you.
>     Yuta
>

--
--------------------------------------------
<KDDI総合研究所 ビジョン>
Challenge for the future 豊かな未来への挑戦
--------------------------------------------
Tomorrow, Together  KDDI
---------------------------------------------
   〒356-8502
 埼玉県ふじみ野市大原2丁目1番15号
 株式会社 KDDI総合研究所(KDDI Research, Inc.)
 コネクティッドカー1G
 森澤 雄太
 mail [hidden email]
 tel  070-3871-8883
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 この電子メールおよび添付書類は、名宛人のための
 特別な秘密情報を含んでおります。
 そのため、名宛人以外の方による利用は認められて
 おりません。
 名宛人以外の方による通信内容公表、複写、転用等
 は厳禁であり、違法となることがあります。
 万が一、何らかの誤りによりこの電子メールを名宛
 人以外の方が受信された場合は、お手数でも、直ち
 に発信人にお知らせ頂くと同時に、当メールを削除
 下さいますようお願い申し上げます。