Get 1 element of DataSet

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Get 1 element of DataSet

Vinh June
Hi,

Is there any way to get 1 element of a DataSet, for example:
----------------------------------------
val stringSet: DataSet[String] = ...
val str: String = stringSet.getFunction()
str
----------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Get 1 element of DataSet

Stefan Bunk
Hi Vinh,


Stefan

On 5 February 2015 at 15:14, Vinh June <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Get 1 element of DataSet

Vinh June
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
Reply | Threaded
Open this post in threaded view
|

Re: Get 1 element of DataSet

Fabian Hueske-2
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 <[hidden email]>:
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.