[
https://issues.apache.org/jira/browse/FLINK-5976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15899270#comment-15899270
]
ASF GitHub Bot commented on FLINK-5976:
---------------------------------------
GitHub user liuyuzhong7 opened a pull request:
https://github.com/apache/flink/pull/3485
FLINK-5976 [tests] Deduplicate Tokenizer in tests
There are some duplicate code like this in flink-test, I think refactor
this will be better.
```
public final class Tokenizer implements FlatMapFunction<String,
Tuple2<String, Integer>> {
@Override
public void flatMap(String value, Collector<Tuple2<String, Integer>>
out) {
// normalize and split the line
String[] tokens = value.toLowerCase().split("\\W+");
// emit the pairs
for (String token : tokens) {
if (token.length() > 0) {
out.collect(new Tuple2<String, Integer>(token,
1));
}
}
}
}
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/liuyuzhong7/flink FLINK-5976
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/3485.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #3485
----
commit db4192110b1b610846f50527a5fc67450d3d1cca
Author: liuyuzhong7 <[email protected]>
Date: 2017-03-07T11:15:40Z
FLINK-5976 [tests] Deduplicate Tokenizer in tests
----
> Refactoring duplicate Tokenizer in flink-test
> ---------------------------------------------
>
> Key: FLINK-5976
> URL: https://issues.apache.org/jira/browse/FLINK-5976
> Project: Flink
> Issue Type: Improvement
> Components: Examples
> Affects Versions: 1.2.0
> Reporter: liuyuzhong7
> Priority: Minor
> Labels: test
> Fix For: 1.2.0
>
>
> There are some duplicate code like this in flink-test, I think refactor this
> will be better.
> ```
> public final class Tokenizer implements FlatMapFunction<String,
> Tuple2<String, Integer>> {
> @Override
> public void flatMap(String value, Collector<Tuple2<String, Integer>>
> out) {
> // normalize and split the line
> String[] tokens = value.toLowerCase().split("\\W+");
> // emit the pairs
> for (String token : tokens) {
> if (token.length() > 0) {
> out.collect(new Tuple2<String, Integer>(token,
> 1));
> }
> }
> }
> }
> ```
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)