| | 104 | |
| | 105 | == Head == |
| | 106 | |
| | 107 | 也是要先生成Configuration和处理参数 |
| | 108 | |
| | 109 | {{{ |
| | 110 | FileSystem hdfs = FileSystem.get(conf); //获得HDFS文件系统的对象 |
| | 111 | |
| | 112 | Path inputDir = new Path(otherArgs[0]); |
| | 113 | if (otherArgs.length > 1) { |
| | 114 | MaxLineNumber = Integer.parseInt(otherArgs[1]) > 0 ? Integer.parseInt(otherArgs[1]) : 10; |
| | 115 | } |
| | 116 | |
| | 117 | byte[] buffer = new byte[4096]; |
| | 118 | FSDataInputStream inputStream = hdfs.open(inputDir); |
| | 119 | |
| | 120 | GzipCodec codec = new GzipCodec(); |
| | 121 | codec.setConf(conf); |
| | 122 | CompressionInputStream input = codec.createInputStream(inputStream); |
| | 123 | }}} |