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


Java TextOutputFormat.setCompressOutput方法代碼示例

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


在下文中一共展示了TextOutputFormat.setCompressOutput方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; //導入方法依賴的package包/類
@Override
	public int run(String[] args) throws Exception {
		SequenceFileIndexerOptions options = new SequenceFileIndexerOptions(args);
		options.prepare();

		Job job = new Job(getConf());
		
		job.setJarByClass(SequenceFileIndexer.class);
		
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		
		job.setMapperClass(RecordIndexMapper.class);
		
		job.setInputFormatClass(SequenceFileInputFormat.class);
		job.setOutputFormatClass(TextOutputFormat.class);
		
		job.setNumReduceTasks(1);
		
		FileInputFormat.setInputPaths(job, options.getInputPaths());
		TextOutputFormat.setOutputPath(job, options.getOutputPath());
		TextOutputFormat.setCompressOutput(job, false);
//		SequenceFileOutputFormat.setOutputCompressorClass(job, DefaultCodec.class);
//		SequenceFileOutputFormat.setOutputCompressionType(job, CompressionType.BLOCK);
		

		job.waitForCompletion(true);
		return 0;
	}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:30,代碼來源:SequenceFileIndexer.java

示例2: stage

import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; //導入方法依賴的package包/類
/**
 * @param inputs
 *            the input paths to be expected
 * @param output
 *            the output location
 * @param conf
 *            the job configuration
 * @return the job to be launched in this stage
 * @throws Exception
 * @throws IOException
 */
public Job stage(Path[] inputs, Path output, Configuration conf) throws Exception {

	final Job job = new Job(conf);
	// A bit of a dirty hack, if any input file is an lzo file sneakily
	// switch the input format class to LZOTextInput
	if (inputFormatClass.equals(TextInputFormat.class) && containsLZO(inputs)) {
		job.setInputFormatClass((Class<? extends InputFormat<?, ?>>) Class
				.forName("com.hadoop.mapreduce.LzoTextInputFormat"));
	}
	else {
		job.setInputFormatClass(inputFormatClass);
	}

	job.setMapOutputKeyClass(mapOutputKeyClass);
	job.setMapOutputValueClass(mapOutputValueClass);
	job.setOutputKeyClass(outputKeyClass);
	job.setOutputValueClass(outputValueClass);
	job.setOutputFormatClass(outputFormatClass);
	if (outputFormatClass.equals(TextOutputFormat.class) && this.lzoCompress()) {
		TextOutputFormat.setCompressOutput(job, true);
		TextOutputFormat.setOutputCompressorClass(job,
				(Class<? extends CompressionCodec>) Class.forName("com.hadoop.compression.lzo.LzopCodec"));
	} else {
		TextOutputFormat.setCompressOutput(job, false);
	}

	job.setJarByClass(this.getClass());
	setInputPaths(job, inputs);
	setOutputPath(job, output);
	setMapperClass(job, mapper());
	setReducerClass(job, reducer());
	setCombinerClass(job, combiner());
	setup(job);
	return job;
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:47,代碼來源:Stage.java


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