You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Mikhail Pryakhin <m....@gmail.com> on 2017/06/13 13:46:45 UTC

RichMapFunction setup method

Hi all!

A RichMapFunction [1] provides a very handy setup method RichFunction#open(org.apache.flink.configuration.Configuration) which consumes a Configuration instance as an argument, but this argument doesn't bear any configuration parameters because it is always passed to the method as a new instance. [2] depicts the problem.

Is there any way to pass configuration parameters to the  RichFunction#open method via the Configuration parameter? Or is it a bug?
P.S. I'm using flink 1.3

Thanks in advance!

[1] https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java
[2] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111

Kind Regards,
Mike Pryakhin










Re: RichMapFunction setup method

Posted by Mikhail Pryakhin <m....@gmail.com>.
Hi Chesnay,
Done. https://issues.apache.org/jira/browse/FLINK-6912 <https://issues.apache.org/jira/browse/FLINK-6912>
Kind Regards,
Mike Pryakhin


> On 13 Jun 2017, at 21:47, Chesnay Schepler <ch...@apache.org> wrote:
> 
> It is a remnant of the past since that method signature originates from the Record API,
> the predecessor of the current DataSet API.
> 
> Even in the DataSet API you can just pass arguments through the constructor.
> Feel free to open a JIRA, just make sure it is a subtask of FLINK-3957.
> 
> On 13.06.2017 16:40, Mikhail Pryakhin wrote:
>> Thanks a lot  Chesnay,
>> 
>> In case it works properly in the Batch API, don’t you think that it should not be called "remnant of the past“?
>> Should I create an issue so we don’t forget about it and may be fix it in the future, I think I’m not the only one who deals with this method.
>> 
>> Kind Regards,
>> Mike Pryakhin
>> 
>> 
>>> On 13 Jun 2017, at 17:20, Chesnay Schepler <chesnay@apache.org <ma...@apache.org>> wrote:
>>> 
>>> I'm not aware of any plans to replace it.
>>> 
>>> For the Batch API it also works properly, so deprecating it would be misleading.
>>> 
>>> On 13.06.2017 16:04, Mikhail Pryakhin wrote:
>>>> Hi Chesnay,
>>>> Thanks for the reply,
>>>> 
>>>>> The existing signature for open() is a remnant of the past.
>>>> 
>>>> Should the method be deprecated then so that it doesn’t confuse users?
>>>> 
>>>> Kind Regards,
>>>> Mike Pryakhin
>>>> 
>>>> 
>>>>> On 13 Jun 2017, at 16:54, Chesnay Schepler <chesnay@apache.org <ma...@apache.org>> wrote:
>>>>> 
>>>>> The existing signature for open() is a remnant of the past.
>>>>> 
>>>>> We currently recommend to pass all arguments through the constructor and store them in fields.
>>>>> You can of course also pass a Configuration containing all parameters.
>>>>> 
>>>>> On 13.06.2017 15:46, Mikhail Pryakhin wrote:
>>>>>> Hi all!
>>>>>> 
>>>>>> A RichMapFunction [1] provides a very handy setup method RichFunction#open(org.apache.flink.configuration.Configuration) which consumes a Configuration instance as an argument, but this argument doesn't bear any configuration parameters because it is always passed to the method as a new instance. [2] depicts the problem.
>>>>>> 
>>>>>> Is there any way to pass configuration parameters to the  RichFunction#open method via the Configuration parameter? Or is it a bug?
>>>>>> P.S. I'm using flink 1.3
>>>>>> 
>>>>>> Thanks in advance!
>>>>>> 
>>>>>> [1] https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java <https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java>
>>>>>> [2] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111 <https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111>
>>>>>> Kind Regards,
>>>>>> Mike Pryakhin
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: RichMapFunction setup method

Posted by Chesnay Schepler <ch...@apache.org>.
It /is /a remnant of the past since that method signature originates 
from the Record API,
the predecessor of the current DataSet API.

Even in the DataSet API you can just pass arguments through the constructor.
Feel free to open a JIRA, just make sure it is a subtask of FLINK-3957.

On 13.06.2017 16:40, Mikhail Pryakhin wrote:
> Thanks a lot  Chesnay,
>
> In case it works properly in the Batch API, don’t you think that it 
> should not be called "remnant of the past“?
> Should I create an issue so we don’t forget about it and may be fix it 
> in the future, I think I’m not the only one who deals with this method.
>
> Kind Regards,
> Mike Pryakhin
>
>
>> On 13 Jun 2017, at 17:20, Chesnay Schepler <chesnay@apache.org 
>> <ma...@apache.org>> wrote:
>>
>> I'm not aware of any plans to replace it.
>>
>> For the Batch API it also works properly, so deprecating it would be 
>> misleading.
>>
>> On 13.06.2017 16:04, Mikhail Pryakhin wrote:
>>> Hi Chesnay,
>>> Thanks for the reply,
>>>
>>>> The existing signature for open() is a remnant of the past.
>>>
>>> Should the method be deprecated then so that it doesn’t confuse users?
>>>
>>> Kind Regards,
>>> Mike Pryakhin
>>>
>>>
>>>> On 13 Jun 2017, at 16:54, Chesnay Schepler <chesnay@apache.org 
>>>> <ma...@apache.org>> wrote:
>>>>
>>>> The existing signature for open() is a remnant of the past.
>>>>
>>>> We currently recommend to pass all arguments through the 
>>>> constructor and store them in fields.
>>>> You can of course also pass a Configuration containing all parameters.
>>>>
>>>> On 13.06.2017 15:46, Mikhail Pryakhin wrote:
>>>>> Hi all!
>>>>>
>>>>> A RichMapFunction [1] provides a very handy setup method 
>>>>> RichFunction#open(org.apache.flink.configuration.Configuration) 
>>>>> which consumes a Configuration instance as an argument, but this 
>>>>> argument doesn't bear any configuration parameters because it is 
>>>>> always passed to the method as a new instance. [2] depicts the 
>>>>> problem.
>>>>>
>>>>> Is there any way to pass configuration parameters to the 
>>>>>  RichFunction#open method via the Configuration parameter? Or is 
>>>>> it a bug?
>>>>> P.S. I'm using flink 1.3
>>>>>
>>>>> Thanks in advance!
>>>>>
>>>>> [1] 
>>>>> https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java
>>>>> [2] 
>>>>> https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111
>>>>>
>>>>> Kind Regards,
>>>>> Mike Pryakhin
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>


Re: RichMapFunction setup method

Posted by Mikhail Pryakhin <m....@gmail.com>.
Thanks a lot  Chesnay,

In case it works properly in the Batch API, don’t you think that it should not be called "remnant of the past“?
Should I create an issue so we don’t forget about it and may be fix it in the future, I think I’m not the only one who deals with this method.

Kind Regards,
Mike Pryakhin


> On 13 Jun 2017, at 17:20, Chesnay Schepler <ch...@apache.org> wrote:
> 
> I'm not aware of any plans to replace it.
> 
> For the Batch API it also works properly, so deprecating it would be misleading.
> 
> On 13.06.2017 16:04, Mikhail Pryakhin wrote:
>> Hi Chesnay,
>> Thanks for the reply,
>> 
>>> The existing signature for open() is a remnant of the past.
>> 
>> Should the method be deprecated then so that it doesn’t confuse users?
>> 
>> Kind Regards,
>> Mike Pryakhin
>> 
>> 
>>> On 13 Jun 2017, at 16:54, Chesnay Schepler <chesnay@apache.org <ma...@apache.org>> wrote:
>>> 
>>> The existing signature for open() is a remnant of the past.
>>> 
>>> We currently recommend to pass all arguments through the constructor and store them in fields.
>>> You can of course also pass a Configuration containing all parameters.
>>> 
>>> On 13.06.2017 15:46, Mikhail Pryakhin wrote:
>>>> Hi all!
>>>> 
>>>> A RichMapFunction [1] provides a very handy setup method RichFunction#open(org.apache.flink.configuration.Configuration) which consumes a Configuration instance as an argument, but this argument doesn't bear any configuration parameters because it is always passed to the method as a new instance. [2] depicts the problem.
>>>> 
>>>> Is there any way to pass configuration parameters to the  RichFunction#open method via the Configuration parameter? Or is it a bug?
>>>> P.S. I'm using flink 1.3
>>>> 
>>>> Thanks in advance!
>>>> 
>>>> [1] https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java <https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java>
>>>> [2] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111 <https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111>
>>>> Kind Regards,
>>>> Mike Pryakhin
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
> 


Re: RichMapFunction setup method

Posted by Chesnay Schepler <ch...@apache.org>.
I'm not aware of any plans to replace it.

For the Batch API it also works properly, so deprecating it would be 
misleading.

On 13.06.2017 16:04, Mikhail Pryakhin wrote:
> Hi Chesnay,
> Thanks for the reply,
>
>> The existing signature for open() is a remnant of the past.
>
> Should the method be deprecated then so that it doesn’t confuse users?
>
> Kind Regards,
> Mike Pryakhin
>
>
>> On 13 Jun 2017, at 16:54, Chesnay Schepler <chesnay@apache.org 
>> <ma...@apache.org>> wrote:
>>
>> The existing signature for open() is a remnant of the past.
>>
>> We currently recommend to pass all arguments through the constructor 
>> and store them in fields.
>> You can of course also pass a Configuration containing all parameters.
>>
>> On 13.06.2017 15:46, Mikhail Pryakhin wrote:
>>> Hi all!
>>>
>>> A RichMapFunction [1] provides a very handy setup method 
>>> RichFunction#open(org.apache.flink.configuration.Configuration) 
>>> which consumes a Configuration instance as an argument, but this 
>>> argument doesn't bear any configuration parameters because it is 
>>> always passed to the method as a new instance. [2] depicts the problem.
>>>
>>> Is there any way to pass configuration parameters to the 
>>>  RichFunction#open method via the Configuration parameter? Or is it 
>>> a bug?
>>> P.S. I'm using flink 1.3
>>>
>>> Thanks in advance!
>>>
>>> [1] 
>>> https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java
>>> [2] 
>>> https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111
>>>
>>> Kind Regards,
>>> Mike Pryakhin
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>


Re: RichMapFunction setup method

Posted by Mikhail Pryakhin <m....@gmail.com>.
Hi Chesnay,
Thanks for the reply,

> The existing signature for open() is a remnant of the past.

Should the method be deprecated then so that it doesn’t confuse users?

Kind Regards,
Mike Pryakhin


> On 13 Jun 2017, at 16:54, Chesnay Schepler <ch...@apache.org> wrote:
> 
> The existing signature for open() is a remnant of the past.
> 
> We currently recommend to pass all arguments through the constructor and store them in fields.
> You can of course also pass a Configuration containing all parameters.
> 
> On 13.06.2017 15:46, Mikhail Pryakhin wrote:
>> Hi all!
>> 
>> A RichMapFunction [1] provides a very handy setup method RichFunction#open(org.apache.flink.configuration.Configuration) which consumes a Configuration instance as an argument, but this argument doesn't bear any configuration parameters because it is always passed to the method as a new instance. [2] depicts the problem.
>> 
>> Is there any way to pass configuration parameters to the  RichFunction#open method via the Configuration parameter? Or is it a bug?
>> P.S. I'm using flink 1.3
>> 
>> Thanks in advance!
>> 
>> [1] https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java <https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java>
>> [2] https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111 <https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111>
>> Kind Regards,
>> Mike Pryakhin
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 


Re: RichMapFunction setup method

Posted by Chesnay Schepler <ch...@apache.org>.
The existing signature for open() is a remnant of the past.

We currently recommend to pass all arguments through the constructor and 
store them in fields.
You can of course also pass a Configuration containing all parameters.

On 13.06.2017 15:46, Mikhail Pryakhin wrote:
> Hi all!
>
> A RichMapFunction [1] provides a very handy setup method 
> RichFunction#open(org.apache.flink.configuration.Configuration) which 
> consumes a Configuration instance as an argument, but this argument 
> doesn't bear any configuration parameters because it is always passed 
> to the method as a new instance. [2] depicts the problem.
>
> Is there any way to pass configuration parameters to the 
>  RichFunction#open method via the Configuration parameter? Or is it a bug?
> P.S. I'm using flink 1.3
>
> Thanks in advance!
>
> [1] 
> https://github.com/apache/flink/blob/master/flink-core/src/main/java/org/apache/flink/api/common/functions/RichMapFunction.java
> [2] 
> https://github.com/apache/flink/blob/master/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/AbstractUdfStreamOperator.java#L111
>
> Kind Regards,
> Mike Pryakhin
>
>
>
>
>
>
>
>
>