Changes between Version 8 and Version 9 of inputouput


Ignore:
Timestamp:
11/27/2012 09:44:50 AM (13 years ago)
Author:
liaojiaohe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • inputouput

    v8 v9  
    116116 
    117117使用文件做输出 
     118 
     119和输入的类对应[[BR]] 
     120TextOutputFormat 默认的输出格式, 以 "key \t value" 的方式输出行[[BR]] 
     121 
     122 
     123SequenceFileOutputFormat[[BR]] 
     124输出二进制文件,适合于读取为子MapReduce作业的输入[[BR]] 
     125 
     126NullOutputFormat输出到/dev/null[[BR]] 
     127 
     128MultipleSequenceFileOutputFormat, MultipleTextOutputFormat,根据key将记录输出到不同的文件[[BR]] 
     129上面两个类主要是可以让不同的类使用不同的文件,具体做法覆盖方法generateFileNameForKeyValue 
     130 
     131 
     132{{{ 
     133        @Override 
     134        protected String generateFileNameForKeyValue(Text key, Text value, 
     135                TaskAttemptContext conf) { 
     136            String CREATE_TIME = conf.getConfiguration().get( 
     137                    Constant.USER_JOB_RUNING_TIME); 
     138            String extension = "_" + CREATE_TIME + "_" + key.toString(); 
     139 
     140            try { 
     141                return super.getDefaultWorkFile(conf, extension).getName().replaceAll("-", ""); 
     142            } catch (IOException e) { 
     143                return extension; 
     144            } 
     145        } 
     146}}} 
     147 
     148 
     149 
     150我们继承了MultipleFileOutputFormat写了一个PCMultipleFileOutputFormat,增加了可以只输出value和可以设置key,value之间分割符的功能