Search in sources :

Example 1 with Sentence

use of org.apache.flink.storm.wordcount.operators.WordCountDataPojos.Sentence in project flink by apache.

the class BoltTokenizerWordCountPojo method main.

// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(final String[] args) throws Exception {
    if (!parseParameters(args)) {
        return;
    }
    // set up the execution environment
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    // get input data
    final DataStream<Sentence> text = getTextDataStream(env);
    final DataStream<Tuple2<String, Integer>> counts = text.transform("BoltTokenizerPojo", TypeExtractor.getForObject(new Tuple2<String, Integer>("", 0)), new BoltWrapper<Sentence, Tuple2<String, Integer>>(new BoltTokenizerByName())).keyBy(0).sum(1);
    // emit result
    if (fileOutput) {
        counts.writeAsText(outputPath);
    } else {
        counts.print();
    }
    // execute program
    env.execute("Streaming WordCount with POJO bolt tokenizer");
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) BoltTokenizerByName(org.apache.flink.storm.wordcount.operators.BoltTokenizerByName) Sentence(org.apache.flink.storm.wordcount.operators.WordCountDataPojos.Sentence)

Aggregations

Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 BoltTokenizerByName (org.apache.flink.storm.wordcount.operators.BoltTokenizerByName)1 Sentence (org.apache.flink.storm.wordcount.operators.WordCountDataPojos.Sentence)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1