You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Vinh June <ho...@gmail.com> on 2015/02/05 15:14:10 UTC

Get 1 element of DataSet

Hi,

Is there any way to get 1 element of a DataSet, for example:
----------------------------------------
val stringSet: DataSet[String] = ...
val str: String = stringSet.getFunction()
str
----------------------------------------



--
View this message in context: http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Get-1-element-of-DataSet-tp688.html
Sent from the Apache Flink (Incubator) User Mailing List archive. mailing list archive at Nabble.com.

Re: Get 1 element of DataSet

Posted by Fabian Hueske <fh...@gmail.com>.
Have a look at "broadcast values/sets".

Not sure if that solves you problem, but you could do:

DataSet<String> stringSet = ...
DataSet<String> first = stringSet.first();

DataSet myNewSet = stringSet.map(myMapFnc).withBroadcastSet(first,"first
value");

This distributes the first DataSet to all Mapper functions and you can read
and use the value.

Cheers, Fabian

2015-02-05 15:34 GMT+01:00 Vinh June <ho...@gmail.com>:

> Hi Stefan,
>
> DataSet.first(n) produces a child DataSet, while I need the element
>
> Specifically, I have a CSV with header line and I want to make the maps of
> each (header,value) pair for each line
>
>
>
> --
> View this message in context:
> http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Get-1-element-of-DataSet-tp688p692.html
> Sent from the Apache Flink (Incubator) User Mailing List archive. mailing
> list archive at Nabble.com.
>

Re: Get 1 element of DataSet

Posted by Vinh June <ho...@gmail.com>.
Hi Stefan,

DataSet.first(n) produces a child DataSet, while I need the element

Specifically, I have a CSV with header line and I want to make the maps of
each (header,value) pair for each line



--
View this message in context: http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Get-1-element-of-DataSet-tp688p692.html
Sent from the Apache Flink (Incubator) User Mailing List archive. mailing list archive at Nabble.com.

Re: Get 1 element of DataSet

Posted by Stefan Bunk <st...@googlemail.com>.
Hi Vinh,

have a look at the first function:
http://flink.apache.org/docs/0.8/dataset_transformations.html#first-n

Stefan

On 5 February 2015 at 15:14, Vinh June <ho...@gmail.com> wrote:

> Hi,
>
> Is there any way to get 1 element of a DataSet, for example:
> ----------------------------------------
> val stringSet: DataSet[String] = ...
> val str: String = stringSet.getFunction()
> str
> ----------------------------------------
>
>
>
> --
> View this message in context:
> http://apache-flink-incubator-user-mailing-list-archive.2336050.n4.nabble.com/Get-1-element-of-DataSet-tp688.html
> Sent from the Apache Flink (Incubator) User Mailing List archive. mailing
> list archive at Nabble.com.
>