Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-5976

Refactoring duplicate Tokenizer in flink-test

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.3.0
    • Component/s: Examples
    • Labels:

      Description

      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)); }

      }
      }
      }

      ```

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              liuyuzhong7 liuyuzhong7
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: