You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Ahmed Nader <ah...@gmail.com> on 2016/03/16 12:37:39 UTC

Convert Datastream to Collector or List

Hi,
I want to pass an object of type DataStream ,after applying map function on
it, as a parameter to be used somewhere else. But when i do so, i get an
error message of trying to access a null context object.
Is there a way that i can convert this DataStream object to a list or a
collector so as to be used somewhere else afterwards.
Thanks,
Ahmed

Re: Convert Datastream to Collector or List

Posted by Ahmed Nader <ah...@gmail.com>.
Hello Suneel,
Yeah that worked, thanks so much.

On 16 March 2016 at 12:50, Suneel Marthi <sm...@apache.org> wrote:

> DataStream<String> ds = .......
>
> Iterator<String> iter = DataStreamUtils.collect(ds);
>
> List<String> list = Lists.newArrayList(iterator);
>
> Hope that helps.
>
>
> On Wed, Mar 16, 2016 at 7:37 AM, Ahmed Nader <ah...@gmail.com>
> wrote:
>
>> Hi,
>> I want to pass an object of type DataStream ,after applying map function
>> on it, as a parameter to be used somewhere else. But when i do so, i get an
>> error message of trying to access a null context object.
>> Is there a way that i can convert this DataStream object to a list or a
>> collector so as to be used somewhere else afterwards.
>> Thanks,
>> Ahmed
>>
>
>

Re: Convert Datastream to Collector or List

Posted by Suneel Marthi <sm...@apache.org>.
DataStream<String> ds = .......

Iterator<String> iter = DataStreamUtils.collect(ds);

List<String> list = Lists.newArrayList(iterator);

Hope that helps.


On Wed, Mar 16, 2016 at 7:37 AM, Ahmed Nader <ah...@gmail.com>
wrote:

> Hi,
> I want to pass an object of type DataStream ,after applying map function
> on it, as a parameter to be used somewhere else. But when i do so, i get an
> error message of trying to access a null context object.
> Is there a way that i can convert this DataStream object to a list or a
> collector so as to be used somewhere else afterwards.
> Thanks,
> Ahmed
>