Skip to content

Commit c257f7e

Browse files
committed
COMPRESSION-11 Add compatability class for files compressed with Hadoop's
compression class.
1 parent 8bfdf82 commit c257f7e

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

CHANGES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ Trunk:
88
COMPRESS-2. Add a new native loader, since Hadoop's doesn't know about the
99
new library (johan via omalley)
1010

11+
COMPRESS-11. Add a compatability class for reading data that was compressed
12+
by Hadoop's class. (hong via omalley)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is part of Hadoop-Gpl-Compression.
3+
*
4+
* Hadoop-Gpl-Compression is free software: you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or (at your
7+
* option) any later version.
8+
*
9+
* Hadoop-Gpl-Compression is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12+
* details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with
15+
* Hadoop-Gpl-Compression. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
package org.apache.hadoop.io.compress;
18+
19+
import java.io.IOException;
20+
import java.io.OutputStream;
21+
22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
24+
25+
/**
26+
* This is a bridging class whose sole purpose is to provide backward
27+
* compatibility of applications that historically depend on
28+
* {@link org.apache.hadoop.io.compress.LzoCodec} (such as SequenceFile).
29+
*
30+
* The class is marked as @deprecated and should not be used explicitly in the
31+
* future.
32+
*
33+
* A warning message will be generated when a user wants to use this class to
34+
* generate LZO compressed data. Not the case for decompression because this is
35+
* the legitimate backward compatibility usage.
36+
*/
37+
@Deprecated
38+
public class LzoCodec extends com.hadoop.compression.lzo.LzoCodec {
39+
private static final Log LOG = LogFactory.getLog(LzoCodec.class);
40+
41+
static final String oahLzoCodec = LzoCodec.class.getName();
42+
static final String chclLzoCodec =
43+
com.hadoop.compression.lzo.LzoCodec.class.getName();
44+
static boolean warned = false;
45+
46+
static {
47+
LOG.info("Bridging " + oahLzoCodec + " to " + chclLzoCodec + ".");
48+
}
49+
50+
public CompressionOutputStream createOutputStream(OutputStream out,
51+
Compressor compressor) throws IOException {
52+
if (!warned) {
53+
LOG.warn(oahLzoCodec + " is deprecated. You should use " + chclLzoCodec
54+
+ " instead to generate LZO compressed data.");
55+
warned = true;
56+
}
57+
return super.createOutputStream(out, compressor);
58+
}
59+
}

0 commit comments

Comments
 (0)