lidox
lidox

Reputation: 1971

Convert a List / Map to org.apache.flink.util.Collector

How can I convert a List / Map to org.apache.flink.util.Collector?

Lets say I have this:

List<Tuple2<Double, Integer>> list = new ArrayList<Tuple2<Double, Integer>>();

And I want to get something like this:

Collector<Tuple2<Double, Integer>> data = ... list.getCollector();

Any Ideas?

Upvotes: 0

Views: 641

Answers (2)

lidox
lidox

Reputation: 1971

Thanks to @karelss

This is the solution:

List<Tuple2<Double, Integer>> list = new ArrayList<Tuple2<Double, Integer>>();
list.add(...);
Collector<Tuple2<Double, Integer>> data = new ListCollector<>(list);

Upvotes: 1

Javier Toja
Javier Toja

Reputation: 1762

Try to use this ListCollector as bridge, with this class you can translate your List (ArrayList) into a Collector(ListCollector), using the constructor

Upvotes: 1

Related Questions