You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Flavio Pompermaier <po...@okkam.it> on 2015/04/16 09:09:09 UTC

Concurrency on fields within operators

Hi to all,
I have a simple question: are transient fields inside a Rich-Function
 (like a RichMapPartition) thread-safe or not?

Best,
Flavio

Re: Concurrency on fields within operators

Posted by Flavio Pompermaier <po...@okkam.it>.
Ok thanks a lot for the confirmation! Thread-safety within operators is
absolutely helpful :)

On Thu, Apr 16, 2015 at 9:20 AM, Robert Metzger <rm...@apache.org> wrote:

> Hi Flavio,
>
> tl;dr: they are thread safe.
>
> making a field transient means that it is ignored when serializing the
> class. This is for example useful when you have a non-serializable field in
> your function (you have to initialize it in the open() method then).
> So making it transient or not doesn't change the fields thread safety.
> Flink doesn't call the user defined functions concurrently (=from multiple
> threads), so you don't need to worry about thread safety.
> The only case you need to worry about thread safety in your
> (Rich-)Function is when you're starting threads yourself inside the
> Function.
>
>
> On Thu, Apr 16, 2015 at 9:09 AM, Flavio Pompermaier <po...@okkam.it>
> wrote:
>
>> Hi to all,
>> I have a simple question: are transient fields inside a Rich-Function
>>  (like a RichMapPartition) thread-safe or not?
>>
>> Best,
>> Flavio
>>
>>

Re: Concurrency on fields within operators

Posted by Robert Metzger <rm...@apache.org>.
Hi Flavio,

tl;dr: they are thread safe.

making a field transient means that it is ignored when serializing the
class. This is for example useful when you have a non-serializable field in
your function (you have to initialize it in the open() method then).
So making it transient or not doesn't change the fields thread safety.
Flink doesn't call the user defined functions concurrently (=from multiple
threads), so you don't need to worry about thread safety.
The only case you need to worry about thread safety in your (Rich-)Function
is when you're starting threads yourself inside the Function.


On Thu, Apr 16, 2015 at 9:09 AM, Flavio Pompermaier <po...@okkam.it>
wrote:

> Hi to all,
> I have a simple question: are transient fields inside a Rich-Function
>  (like a RichMapPartition) thread-safe or not?
>
> Best,
> Flavio
>
>