You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by "yinhua.dai" <yi...@outlook.com> on 2019/03/14 05:51:22 UTC
What should I take care if I enable object reuse
Hi Community,
I saw from the document that we need to be careful about enable the object
reuse feature.
So which part should I check to avoid any issues? Can any one help to
summarize?
Thank you.
//////
*enableObjectReuse() / disableObjectReuse()* By default, objects are not
reused in Flink. Enabling the object reuse mode will instruct the runtime to
reuse user objects for better performance. Keep in mind that this can lead
to bugs when the user-code function of an operation is not aware of this
behavior.
--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Re: What should I take care if I enable object reuse
Posted by "yinhua.dai" <yi...@outlook.com>.
Get it, thanks guys
--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Re: What should I take care if I enable object reuse
Posted by Elias Levy <fe...@gmail.com>.
That's certainly the safe thing to do, but if you do not mutate the object,
a copy is not strictly necessary.
On Thu, Mar 14, 2019 at 9:19 PM Kurt Young <yk...@gmail.com> wrote:
> Keep one thing in mind: if you want the element remains legal after the
> function call ends (maybe map(), flatmap(), depends on what you are using),
> you should copy the elements.
> Typical scenarios includes:
> 1. Save the elements into some collection like array, list, map for later
> usage, you should copy it explicitly.
> 2. Pass the element into some async calls, you should copy it.
>
> Best,
> Kurt
>
>
> On Fri, Mar 15, 2019 at 8:45 AM yinhua.dai <yi...@outlook.com>
> wrote:
>
>> Hi Elias,
>>
>> Thanks.
>> Would it be good enough as long as we use always use different object when
>> call the Collector.collect() method in the operator?
>>
>>
>>
>> --
>> Sent from:
>> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>>
>
Re: What should I take care if I enable object reuse
Posted by Kurt Young <yk...@gmail.com>.
Keep one thing in mind: if you want the element remains legal after the
function call ends (maybe map(), flatmap(), depends on what you are using),
you should copy the elements.
Typical scenarios includes:
1. Save the elements into some collection like array, list, map for later
usage, you should copy it explicitly.
2. Pass the element into some async calls, you should copy it.
Best,
Kurt
On Fri, Mar 15, 2019 at 8:45 AM yinhua.dai <yi...@outlook.com> wrote:
> Hi Elias,
>
> Thanks.
> Would it be good enough as long as we use always use different object when
> call the Collector.collect() method in the operator?
>
>
>
> --
> Sent from:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>
Re: What should I take care if I enable object reuse
Posted by "yinhua.dai" <yi...@outlook.com>.
Hi Elias,
Thanks.
Would it be good enough as long as we use always use different object when
call the Collector.collect() method in the operator?
--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
Re: What should I take care if I enable object reuse
Posted by Elias Levy <fe...@gmail.com>.
Avoid mutating the object if you keep a reference to it within an operator.
On Wed, Mar 13, 2019 at 11:51 PM yinhua.dai <yi...@outlook.com> wrote:
> Hi Community,
>
> I saw from the document that we need to be careful about enable the object
> reuse feature.
> So which part should I check to avoid any issues? Can any one help to
> summarize?
> Thank you.
>
> //////
> *enableObjectReuse() / disableObjectReuse()* By default, objects are not
> reused in Flink. Enabling the object reuse mode will instruct the runtime
> to
> reuse user objects for better performance. Keep in mind that this can lead
> to bugs when the user-code function of an operation is not aware of this
> behavior.
>
>
>
> --
> Sent from:
> http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/
>