當前位置: 首頁>>代碼示例>>Java>>正文


Java WordCountData.getDefaultTextLineDataSet方法代碼示例

本文整理匯總了Java中org.apache.flink.examples.java.wordcount.util.WordCountData.getDefaultTextLineDataSet方法的典型用法代碼示例。如果您正苦於以下問題:Java WordCountData.getDefaultTextLineDataSet方法的具體用法?Java WordCountData.getDefaultTextLineDataSet怎麽用?Java WordCountData.getDefaultTextLineDataSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.flink.examples.java.wordcount.util.WordCountData的用法示例。


在下文中一共展示了WordCountData.getDefaultTextLineDataSet方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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


注:本文中的org.apache.flink.examples.java.wordcount.util.WordCountData.getDefaultTextLineDataSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。