| | 118 | |
| | 119 | 和输入的类对应[[BR]] |
| | 120 | TextOutputFormat 默认的输出格式, 以 "key \t value" 的方式输出行[[BR]] |
| | 121 | |
| | 122 | |
| | 123 | SequenceFileOutputFormat[[BR]] |
| | 124 | 输出二进制文件,适合于读取为子MapReduce作业的输入[[BR]] |
| | 125 | |
| | 126 | NullOutputFormat输出到/dev/null[[BR]] |
| | 127 | |
| | 128 | MultipleSequenceFileOutputFormat, 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之间分割符的功能 |