|
| 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