Skip to content

Initial try#2922

Closed
vipul1409 wants to merge 2 commits into
apache:masterfrom
vipul1409:rich-flat-map
Closed

Initial try#2922
vipul1409 wants to merge 2 commits into
apache:masterfrom
vipul1409:rich-flat-map

Conversation

@vipul1409
Copy link
Copy Markdown

@vipul1409 vipul1409 commented Dec 2, 2016

MultiThreadedFlatMapFunction provides an interface to execute execute flatmap using a set of threads. We can specify number of threads in the Constructor.

Usage flatMap(new MultiThreadedFlatMapFunction<String, Tuple2<String, Integer>>(new Tokenizer(),10)). Refer https://github.com/apache/flink/pull/2922/files#diff-27952c7e65576c8436355775051d8abb for usage example.

Please let me know if more details are needed.

// split up the lines in pairs (2-tuples) containing: (word,1)
//text.flatMap(new Tokenizer()).keyBy(0).sum(1);
text.flatMap(new MultiThreadedFlatMapFunction<String, Tuple2<String, Integer>>(new Tokenizer(),10)).
returns(new TypeHint<Tuple2<String, Integer>>(){}).keyBy(0).sum(1);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I avoid return call somehow?

futures.add(flatMapExecutors.submit(new Callable<ArrayList<OUT>>() {
@Override
public ArrayList<OUT> call() throws Exception {
ArrayList<OUT> result = new ArrayList<OUT>();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As each call may take significant time we need to ensure that all the results objects of active threads can stay in memory.

@Override
public ArrayList<OUT> call() throws Exception {
ArrayList<OUT> result = new ArrayList<OUT>();
Collector<OUT> collector = new ListCollector<OUT>(result);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions on which collector would be a good choice over here. I am not aware of all the options. Is there any document available for different collectors.

@zentol
Copy link
Copy Markdown
Contributor

zentol commented Dec 2, 2016

Please include a description of the PR in the Title (including the relevant JIRA) and main post; we can't review it like this.

@vipul1409 vipul1409 closed this Dec 2, 2016
@vipul1409
Copy link
Copy Markdown
Author

Closing pull request as this is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants