WindowWordCountLocal.java 1.8 KB
Newer Older
Y
Yingjun Wu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/***********************************************************************************************************************
 *
 * Copyright (C) 2010-2014 by the Stratosphere project (http://stratosphere.eu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 **********************************************************************************************************************/

16
package eu.stratosphere.streaming.examples.window.wordcount;
Y
Yingjun Wu 已提交
17

18 19 20
import eu.stratosphere.api.java.tuple.Tuple3;
import eu.stratosphere.streaming.api.DataStream;
import eu.stratosphere.streaming.api.StreamExecutionEnvironment;
Y
Yingjun Wu 已提交
21

22
public class WindowWordCountLocal {
Y
Yingjun Wu 已提交
23

24 25 26
	private static final int PARALELISM = 1;
	private static final int SOURCE_PARALELISM = 1;

27 28
	// This example will count the occurrence of each word in the input file with a sliding window.
	
29
	public static void main(String[] args) {
30
		StreamExecutionEnvironment env = new StreamExecutionEnvironment();
M
Márton Balassi 已提交
31
		
32
		@SuppressWarnings("unused")
M
Márton Balassi 已提交
33
		DataStream<Tuple3<String, Integer, Long>> dataStream = env
34 35
				.addSource(new WindowWordCountSource(), SOURCE_PARALELISM)
				.flatMap(new WindowWordCountSplitter(), PARALELISM)
36
				.partitionBy(0)
37
				.flatMap(new WindowWordCountCounter(), PARALELISM)
38 39
				.addSink(new WindowWordCountSink());
		
M
Márton Balassi 已提交
40
		env.execute();
41
	}
Y
Yingjun Wu 已提交
42
}