pom配置
<dependency>
<groupId>org.anarres.lzo</groupId>
<artifactId>lzo-hadoop</artifactId>
<version>${lzo.version}</version>
</dependency>
Lzo配置
Configuration configuration = new Configuration();
configuration.set("io.compression.codecs", "com.hadoop.compression.lzo.LzoCodec");
configuration.set("fs.defaultFS","");
Java代码
LzopCodec lzo = null;
try {
lzo = new LzopCodec();
lzo.setConf(HDFSUtils.getLzoDefaultConf()); //为Lzo配置项
is = lzo.createInputStream(fs.open(lzoFilePath)); // fs为FileSystem对象
isr = new InputStreamReader(is);
reader = new BufferedReader(isr);
while ((line = reader.readLine()) != null) {
// Process
}
}