You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Chirag Dewan <ch...@yahoo.in> on 2018/10/04 10:14:26 UTC

FlinkUserClassLoader in AggregateFunction

Hi All,
Is there any other way to get hold of the FlinkUserClassLoaderother than the RuntimeContext?
The problem is, AggregateFunction cant be a RichFunction. I understand that's because of the state merging issue(from a thread here earlier). Now, I need DynamicClassLoading in AggregateFunction. And apparently, the only way to get a UserClassLoader is through the RuntimeContext.

Any workaround around this? Or someway I can create my custom UserClassLoader in the AggregateFunction?

Thanks in advance!
Chirag

Re: FlinkUserClassLoader in AggregateFunction

Posted by Chirag Dewan <ch...@yahoo.in>.
 That worked pretty well. Thank you so much Aljoscha :) 
   On Thursday, 4 October, 2018, 5:40:17 PM IST, Aljoscha Krettek <al...@apache.org> wrote: 
 
 Hi,
you are right in that you can't get it from the RuntimeContext because AggregateFunction doesn't have access to that. As an alternative, you can use Thread.currentThread().getContextClassLoader(), which always should have the user-code ClassLoader set.
Best,Aljoscha


On 4. Oct 2018, at 12:14, Chirag Dewan <ch...@yahoo.in> wrote:
Hi All,
Is there any other way to get hold of the FlinkUserClassLoaderother than the RuntimeContext?
The problem is, AggregateFunction cant be a RichFunction. I understand that's because of the state merging issue(from a thread here earlier). Now, I need DynamicClassLoading in AggregateFunction. And apparently, the only way to get a UserClassLoader is through the RuntimeContext.

Any workaround around this? Or someway I can create my custom UserClassLoader in the AggregateFunction?

Thanks in advance!
Chirag

  

Re: FlinkUserClassLoader in AggregateFunction

Posted by Aljoscha Krettek <al...@apache.org>.
Hi,

you are right in that you can't get it from the RuntimeContext because AggregateFunction doesn't have access to that. As an alternative, you can use Thread.currentThread().getContextClassLoader(), which always should have the user-code ClassLoader set.

Best,
Aljoscha

> On 4. Oct 2018, at 12:14, Chirag Dewan <ch...@yahoo.in> wrote:
> 
> Hi All,
> 
> Is there any other way to get hold of the FlinkUserClassLoaderother than the RuntimeContext?
> 
> The problem is, AggregateFunction cant be a RichFunction. I understand that's because of the state merging issue(from a thread here earlier). Now, I need DynamicClassLoading in AggregateFunction. And apparently, the only way to get a UserClassLoader is through the RuntimeContext.
> 
> 
> Any workaround around this? Or someway I can create my custom UserClassLoader in the AggregateFunction?
> 
> Thanks in advance!
> 
> Chirag