Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'origin/master' into compression_level

  • Loading branch information...
commit 4a7b0fe18ee154762c9832d2f40f242247c27fb6 2 parents 3d8386a + fff5518
@traviscrawford traviscrawford authored
View
2  build.xml
@@ -28,7 +28,7 @@
<property name="Name" value="Hadoop GPL Compression"/>
<property name="name" value="hadoop-lzo"/>
- <property name="version" value="0.4.10"/>
+ <property name="version" value="0.4.11"/>
<property name="final.name" value="${name}-${version}"/>
<property name="year" value="2008"/>
View
2  src/java/com/hadoop/compression/lzo/LzopOutputStream.java
@@ -177,7 +177,7 @@ protected void compress() throws IOException {
// the LZO specification says that we should write the uncompressed bytes rather
// than the compressed bytes. The decompressor understands this because both sizes
// get written to the stream.
- if (compressor.getBytesRead() < compressor.getBytesWritten()) {
+ if (compressor.getBytesRead() <= compressor.getBytesWritten()) {
// Compression actually increased the size of the buffer, so write the uncompressed bytes.
byte[] uncompressed = ((LzoCompressor)compressor).uncompressedBytes();
rawWriteInt(uncompressed.length);
View
20 src/test/com/hadoop/compression/lzo/TestLzopOutputStream.java
@@ -46,6 +46,7 @@
private final String bigFile = "100000.txt";
private final String mediumFile = "1000.txt";
private final String smallFile = "100.txt";
+ private final String issue20File = "issue20-lzop.txt";
@Override
protected void setUp() throws Exception {
@@ -85,6 +86,25 @@ public void testSmallFile() throws NoSuchAlgorithmException, IOException,
}
/**
+ * The LZO specification says that we should write the uncompressed bytes
+ * rather than the compressed bytes if the compressed buffer is actually
+ * larger ('&gt;') than the uncompressed buffer.
+ *
+ * To conform to the standard, this means we have to write the uncompressed
+ * bytes also when they have exactly the same size as the compressed bytes.
+ * (the '==' in '&lt;=').
+ *
+ * The input data of this test is known to compress to the same size as the
+ * uncompressed data. Hence we verify that we handle the boundary condition
+ * correctly.
+ *
+ */
+ public void testIssue20File() throws NoSuchAlgorithmException, IOException,
+ InterruptedException {
+ runTest(issue20File);
+ }
+
+ /**
* Test that reading an lzo-compressed file produces the same lines as reading the equivalent
* flat file. The test opens both the compressed and flat file, successively reading each
* line by line and comparing.
View
6 src/test/data/issue20-lzop.txt
@@ -0,0 +1,6 @@
+0.5 74 25425
+0.9 200 25384
+0.95 203 4
+0.98 211 2
+0.99 219 3
+0.995 240 5
Please sign in to comment.
Something went wrong with that request. Please try again.