Package org.apache.hadoop.io.compress
Class CompressionCodecFactory
java.lang.Object
org.apache.hadoop.io.compress.CompressionCodecFactory
A factory that will find the correct codec for a given filename.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFind the codecs specified in the config value io.compression.codecs and register them. -
Method Summary
Modifier and TypeMethodDescriptionFind the relevant compression codec for the given file based on its filename suffix.getCodecByClassName(String classname) Find the relevant compression codec for the codec's canonical class name.getCodecByName(String codecName) Find the relevant compression codec for the codec's canonical class name or by codec alias.Class<? extends CompressionCodec>getCodecClassByName(String codecName) Find the relevant compression codec for the codec's canonical class name or by codec alias and returns its implemetation class.static List<Class<? extends CompressionCodec>>getCodecClasses(Configuration conf) Get the list of codecs discovered via a Java ServiceLoader, or listed in the configuration.static voidA little test program.static StringremoveSuffix(String filename, String suffix) Removes a suffix from a filename, if it has it.static voidsetCodecClasses(Configuration conf, List<Class> classes) Sets a list of codec classes in the configuration.toString()Print the extension map out as a string.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
CompressionCodecFactory
Find the codecs specified in the config value io.compression.codecs and register them. Defaults to gzip and deflate.- Parameters:
conf- configuration.
-
-
Method Details
-
toString
Print the extension map out as a string. -
getCodecClasses
Get the list of codecs discovered via a Java ServiceLoader, or listed in the configuration. Codecs specified in configuration come later in the returned list, and are considered to override those from the ServiceLoader.- Parameters:
conf- the configuration to look in- Returns:
- a list of the
CompressionCodecclasses
-
setCodecClasses
Sets a list of codec classes in the configuration. In addition to any classes specified using this method,CompressionCodecclasses on the classpath are discovered using a Java ServiceLoader.- Parameters:
conf- the configuration to modifyclasses- the list of classes to set
-
getCodec
Find the relevant compression codec for the given file based on its filename suffix.- Parameters:
file- the filename to check- Returns:
- the codec object
-
getCodecByClassName
Find the relevant compression codec for the codec's canonical class name.- Parameters:
classname- the canonical class name of the codec- Returns:
- the codec object
-
getCodecByName
Find the relevant compression codec for the codec's canonical class name or by codec alias.Codec aliases are case insensitive.
The code alias is the short class name (without the package name). If the short class name ends with 'Codec', then there are two aliases for the codec, the complete short class name and the short class name without the 'Codec' ending. For example for the 'GzipCodec' codec class name the alias are 'gzip' and 'gzipcodec'.
- Parameters:
codecName- the canonical class name of the codec- Returns:
- the codec object
-
getCodecClassByName
Find the relevant compression codec for the codec's canonical class name or by codec alias and returns its implemetation class.Codec aliases are case insensitive.
The code alias is the short class name (without the package name). If the short class name ends with 'Codec', then there are two aliases for the codec, the complete short class name and the short class name without the 'Codec' ending. For example for the 'GzipCodec' codec class name the alias are 'gzip' and 'gzipcodec'.
- Parameters:
codecName- the canonical class name of the codec- Returns:
- the codec class
-
removeSuffix
Removes a suffix from a filename, if it has it.- Parameters:
filename- the filename to stripsuffix- the suffix to remove- Returns:
- the shortened filename
-
main
A little test program.- Parameters:
args- arguments.- Throws:
Exception- exception.
-