Skip to content

Commit

Permalink
incoporated code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxutw committed Apr 24, 2012
1 parent 793a132 commit 70d6a07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/java/com/hadoop/compression/lzo/LzopCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,9 @@ public CompressionInputStream createInputStream(InputStream in,

@Override
public CompressionInputStream createInputStream(InputStream in) throws IOException {
// Ensure native-lzo library is loaded & initialized
if (!isNativeLzoLoaded(getConf())) {
throw new RuntimeException("native-lzo library not available");
}
/*create a decompressor and tell LzoInputStream to reuse it
/*create a decompressor and tell LzoInputStream to reuse it
* (return it to the pool when LzoInputStream is closed.
*/

return new LzopInputStream(in, CodecPool.getDecompressor(this),
getConf().getInt(LZO_BUFFER_SIZE_KEY, DEFAULT_LZO_BUFFER_SIZE), true);
}
Expand Down
5 changes: 3 additions & 2 deletions src/java/com/hadoop/compression/lzo/LzopInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,15 @@ public void close() throws IOException {
decompressor.decompress(b, 0, b.length);
}
super.close();
if(reuseDecompressor)
CodecPool.returnDecompressor(decompressor);
try {
verifyChecksums();
} catch (IOException e) {
// LZO requires that each file ends with 4 trailing zeroes. If we are here,
// the file didn't. It's not critical, though, so log and eat it in this case.
LOG.warn("Incorrect LZO file format: file did not end with four trailing zeroes.", e);
} finally{
if(reuseDecompressor)
CodecPool.returnDecompressor(decompressor);
}
}
}

0 comments on commit 70d6a07

Please sign in to comment.