how to convert DataStream to DataSet

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

how to convert DataStream to DataSet

subashbasnet
Hello all,

In WikipediaAnalysis.java we get result of type DataStream<Tuple2<String, Long>>,

I would want to convert result to newResult of type DataSet<Tuple1<String>>,

So tried the following: 
DataSet<Tuple1<String>>newResult = result.map(new getResult());

public static final class getResult implements MapFunction<Tuple2<String, Long>, Tuple1<String>> {

@Override
public Tuple1<String> map(Tuple2<String, Long> value) {
return new Tuple1<String>(value.f1 + "");
}
}

But there is type mismatch, with error as:
Type mismatch: cannot convert from SingleOutputStreamOperator<Tuple1<String>> to DataSet<Tuple1<String>>


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

Re: how to convert DataStream to DataSet

Balaji Rajagopalan
There was a similar question before the answer was to use org.apache.flink.api.common.io.OutputFormat to do the conversion. 

On Tue, Mar 15, 2016 at 7:48 PM, subash basnet <[hidden email]> wrote:
Hello all,

In WikipediaAnalysis.java we get result of type DataStream<Tuple2<String, Long>>,

I would want to convert result to newResult of type DataSet<Tuple1<String>>,

So tried the following: 
DataSet<Tuple1<String>>newResult = result.map(new getResult());

public static final class getResult implements MapFunction<Tuple2<String, Long>, Tuple1<String>> {

@Override
public Tuple1<String> map(Tuple2<String, Long> value) {
return new Tuple1<String>(value.f1 + "");
}
}

But there is type mismatch, with error as:
Type mismatch: cannot convert from SingleOutputStreamOperator<Tuple1<String>> to DataSet<Tuple1<String>>


Best Regards,
Subash Basnet