当前位置: 首页>>代码示例>>Java>>正文


Java WordCountData类代码示例

本文整理汇总了Java中org.apache.flink.examples.java.wordcount.util.WordCountData的典型用法代码示例。如果您正苦于以下问题:Java WordCountData类的具体用法?Java WordCountData怎么用?Java WordCountData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WordCountData类属于org.apache.flink.examples.java.wordcount.util包,在下文中一共展示了WordCountData类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextDataSet

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
private static DataSet<String> getTextDataSet(ExecutionEnvironment env) {
	if (fileOutput) {
		// read the text file from given input path
		return env.readTextFile(textPath);
	} else {
		// get default test text data
		return WordCountData.getDefaultTextLineDataSet(env);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:WordCount.java

示例2: getTextDataStream

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
private static DataStream<String> getTextDataStream(StreamExecutionEnvironment env) {
	if (fileOutput) {
		// read the text file from given input path
		return env.readTextFile(textPath);
	} else {
		// get default test text data
		return env.fromElements(WordCountData.WORDS);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:WordCount.java

示例3: main

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up the execution environment
		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		// get input data
		DataSet<String> text;
		if (params.has("input")) {
			// read the text file from given input path
			text = env.readTextFile(params.get("input"));
		} else {
			// get default test text data
			System.out.println("Executing WordCount example with default input data set.");
			System.out.println("Use --input to specify file input.");
			text = WordCountData.getDefaultTextLineDataSet(env);
		}

		DataSet<Tuple2<String, Integer>> counts =
				// split up the lines in pairs (2-tuples) containing: (word,1)
				text.flatMap(new Tokenizer())
				// group by the tuple field "0" and sum up tuple field "1"
				.groupBy(0)
				.sum(1);

		// emit result
		if (params.has("output")) {
			counts.writeAsCsv(params.get("output"), "\n", " ");
			// execute program
			env.execute("WordCount Example");
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			counts.print();
		}

	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:41,代码来源:WordCount.java

示例4: getTextDataSet

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
private static DataSet<String> getTextDataSet(ExecutionEnvironment env) {
	if(fileOutput) {
		// read the text file from given input path
		return env.readTextFile(textPath);
	} else {
		// get default test text data
		return WordCountData.getDefaultTextLineDataSet(env);
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:10,代码来源:PojoExample.java

示例5: main

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		final ParameterTool params = ParameterTool.fromArgs(args);

		// set up the execution environment
		final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

		// make parameters available in the web interface
		env.getConfig().setGlobalJobParameters(params);

		// get input data
		DataSet<String> text;
		if (params.has("input")) {
			// read the text file from given input path
			text = env.readTextFile(params.get("input"));
		} else {
			// get default test text data
			System.out.println("Executing WordCount example with default input data set.");
			System.out.println("Use --input to specify file input.");
			text = WordCountData.getDefaultTextLineDataSet(env);
		}

		DataSet<Word> counts =
			// split up the lines into Word objects (with frequency = 1)
			text.flatMap(new Tokenizer())
			// group by the field word and sum up the frequency
			.groupBy("word")
			.reduce(new ReduceFunction<Word>() {
				@Override
				public Word reduce(Word value1, Word value2) throws Exception {
					return new Word(value1.word, value1.frequency + value2.frequency);
				}
			});

		if (params.has("output")) {
			counts.writeAsText(params.get("output"), WriteMode.OVERWRITE);
			// execute program
			env.execute("WordCount-Pojo Example");
		} else {
			System.out.println("Printing result to stdout. Use --output to specify output path.");
			counts.print();
		}

	}
 
开发者ID:axbaretto,项目名称:flink,代码行数:45,代码来源:WordCountPojo.java

示例6: main

import org.apache.flink.examples.java.wordcount.util.WordCountData; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	StreamExecutionEnvironment env = StreamExecutionEnvironment
			.createLocalEnvironment(PARALLELISM);

	DataStream<String> stream = env.fromElements(WordCountData.WORDS).map(new IdentityMap());

	stream.print();

	env.execute();
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:11,代码来源:BasicTopology.java


注:本文中的org.apache.flink.examples.java.wordcount.util.WordCountData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。