org.apache.flink.examples.java.wordcount.WordCount Java Examples

The following examples show how to use org.apache.flink.examples.java.wordcount.WordCount. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreviewPlanDumpTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example #2
Source File: DumpCompiledPlanTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example #3
Source File: PreviewPlanDumpTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example #4
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void dumpWordCount() {
	// prepare the test environment
	PreviewPlanEnvironment env = new PreviewPlanEnvironment();
	env.setAsContext();
	try {
		WordCount.main(new String[] {
				"--input", IN_FILE,
				"--output", OUT_FILE});
	} catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
		// all good.
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("WordCount failed with an exception");
	}
	dump(env.getPlan());
}
 
Example #5
Source File: WordCountWithCollectionITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> text = env.fromElements(WordCountData.TEXT);
	DataSet<Tuple2<String, Integer>> words = text.flatMap(new WordCount.Tokenizer());
	DataSet<Tuple2<String, Integer>> result = words.groupBy(0).aggregate(Aggregations.SUM, 1);

	result.output(new LocalCollectionOutputFormat<Tuple2<String, Integer>>(resultsCollected));
	env.execute("Word Count Collection");
}
 
Example #6
Source File: WordCountWithCollectionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> text = env.fromElements(WordCountData.TEXT);
	DataSet<Tuple2<String, Integer>> words = text.flatMap(new WordCount.Tokenizer());
	DataSet<Tuple2<String, Integer>> result = words.groupBy(0).aggregate(Aggregations.SUM, 1);

	result.output(new LocalCollectionOutputFormat<Tuple2<String, Integer>>(resultsCollected));
	env.execute("Word Count Collection");
}
 
Example #7
Source File: WordCountWithCollectionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	DataSet<String> text = env.fromElements(WordCountData.TEXT);
	DataSet<Tuple2<String, Integer>> words = text.flatMap(new WordCount.Tokenizer());
	DataSet<Tuple2<String, Integer>> result = words.groupBy(0).aggregate(Aggregations.SUM, 1);

	result.output(new LocalCollectionOutputFormat<Tuple2<String, Integer>>(resultsCollected));
	env.execute("Word Count Collection");
}
 
Example #8
Source File: WordCountITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	WordCount.main(new String[] {
			"--input", textPath,
			"--output", resultPath });
}
 
Example #9
Source File: WordCountITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	WordCount.main(new String[] {
			"--input", textPath,
			"--output", resultPath });
}
 
Example #10
Source File: WordCountITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected void testProgram() throws Exception {
	WordCount.main(new String[] {
			"--input", textPath,
			"--output", resultPath });
}
 
Example #11
Source File: PreviewPlanDumpTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void dumpWordCount() throws Exception {
	verifyPlanDump(WordCount.class,
		"--input", IN_FILE,
		"--output", OUT_FILE);
}
 
Example #12
Source File: DumpCompiledPlanTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void dumpWordCount() throws Exception {
	verifyOptimizedPlan(WordCount.class,
		"--input", IN_FILE,
		"--output", OUT_FILE);
}