Retrieve elements from the Dataset without using collect

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

Retrieve elements from the Dataset without using collect

subashbasnet
Hello all, 

My requirement is to get suppose top '10' elements from the DataSet as another DataSet. How would I do that without using collect. 
Eg:
DataSet<Tuple2<Integer, Double[]>> counts = data.flatMap(new Tokenizer());

I want a new DataSet containing 10 elements of counts

And, what would be the way to retrieve individual elements of DataSet without using list via collect?


Best Regards,
Subash Basnet
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve elements from the Dataset without using collect

snntr
Hi Subash,

I think Dataset.first(int n) is what you are looking for.

Cheers,

Konstantin

On 06.03.2016 19:10, subash basnet wrote:

> Hello all,
>
> My requirement is to get suppose top '10' elements from the DataSet as
> another DataSet. How would I do that without using collect.
> Eg:
> *DataSet<Tuple2<Integer, Double[]>> counts =* *data.flatMap(new
> Tokenizer());*
>
> I want a new DataSet containing 10 elements of *counts*.
>
> And, what would be the way to retrieve individual elements of DataSet
> without using list via collect?
>
>
> Best Regards,
> Subash Basnet

--
Konstantin Knauf * [hidden email] * +49-174-3413182
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Christoph Stock, Dr. Robert Dahlke
Sitz: Unterföhring * Amtsgericht München * HRB 135082
Reply | Threaded
Open this post in threaded view
|

Re: Retrieve elements from the Dataset without using collect

subashbasnet
In reply to this post by subashbasnet
Hello Konstantin,

Yup thanks. 


Best Regards,
Subash Basnet

On Sun, Mar 6, 2016 at 7:20 PM, Konstantin Knauf <[hidden email]> wrote:
Boxbe This message is eligible for Automatic Cleanup! ([hidden email]) Add cleanup rule | More info

Hi Subash,

I think Dataset.first(int n) is what you are looking for.

Cheers,

Konstantin

On 06.03.2016 19:10, subash basnet wrote:
> Hello all,
>
> My requirement is to get suppose top '10' elements from the DataSet as
> another DataSet. How would I do that without using collect.
> Eg:
> *DataSet<Tuple2<Integer, Double[]>> counts =* *data.flatMap(new
> Tokenizer());*
>
> I want a new DataSet containing 10 elements of *counts*.
>
> And, what would be the way to retrieve individual elements of DataSet
> without using list via collect?
>
>
> Best Regards,
> Subash Basnet

--
Konstantin Knauf * [hidden email] * <a href="tel:%2B49-174-3413182" value="+491743413182">+49-174-3413182
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Christoph Stock, Dr. Robert Dahlke
Sitz: Unterföhring * Amtsgericht München * HRB 135082