org.apache.hadoop.io.compress
Class SnappyCodec

java.lang.Object
  extended by org.apache.hadoop.io.compress.SnappyCodec
All Implemented Interfaces:
Configurable, CompressionCodec

public class SnappyCodec
extends Object
implements Configurable, CompressionCodec

This class creates snappy compressors/decompressors.


Constructor Summary
SnappyCodec()
           
 
Method Summary
 Compressor createCompressor()
          Create a new Compressor for use by this CompressionCodec.
 Decompressor createDecompressor()
          Create a new Decompressor for use by this CompressionCodec.
 CompressionInputStream createInputStream(InputStream in)
          Create a CompressionInputStream that will read from the given input stream.
 CompressionInputStream createInputStream(InputStream in, Decompressor decompressor)
          Create a CompressionInputStream that will read from the given InputStream with the given Decompressor.
 CompressionOutputStream createOutputStream(OutputStream out)
          Create a CompressionOutputStream that will write to the given OutputStream.
 CompressionOutputStream createOutputStream(OutputStream out, Compressor compressor)
          Create a CompressionOutputStream that will write to the given OutputStream with the given Compressor.
 Class<? extends Compressor> getCompressorType()
          Get the type of Compressor needed by this CompressionCodec.
 Configuration getConf()
          Return the configuration used by this object.
 Class<? extends Decompressor> getDecompressorType()
          Get the type of Decompressor needed by this CompressionCodec.
 String getDefaultExtension()
          Get the default filename extension for this kind of compression.
static boolean isNativeCodeLoaded()
          Are the native snappy libraries loaded & initialized?
 void setConf(Configuration conf)
          Set the configuration to be used by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnappyCodec

public SnappyCodec()
Method Detail

setConf

public void setConf(Configuration conf)
Set the configuration to be used by this object.

Specified by:
setConf in interface Configurable
Parameters:
conf - the configuration object.

getConf

public Configuration getConf()
Return the configuration used by this object.

Specified by:
getConf in interface Configurable
Returns:
the configuration object used by this objec.

isNativeCodeLoaded

public static boolean isNativeCodeLoaded()
Are the native snappy libraries loaded & initialized?

Returns:
true if loaded & initialized, otherwise false

createOutputStream

public CompressionOutputStream createOutputStream(OutputStream out)
                                           throws IOException
Create a CompressionOutputStream that will write to the given OutputStream.

Specified by:
createOutputStream in interface CompressionCodec
Parameters:
out - the location for the final output stream
Returns:
a stream the user can write uncompressed data to have it compressed
Throws:
IOException

createOutputStream

public CompressionOutputStream createOutputStream(OutputStream out,
                                                  Compressor compressor)
                                           throws IOException
Create a CompressionOutputStream that will write to the given OutputStream with the given Compressor.

Specified by:
createOutputStream in interface CompressionCodec
Parameters:
out - the location for the final output stream
compressor - compressor to use
Returns:
a stream the user can write uncompressed data to have it compressed
Throws:
IOException

getCompressorType

public Class<? extends Compressor> getCompressorType()
Get the type of Compressor needed by this CompressionCodec.

Specified by:
getCompressorType in interface CompressionCodec
Returns:
the type of compressor needed by this codec.

createCompressor

public Compressor createCompressor()
Create a new Compressor for use by this CompressionCodec.

Specified by:
createCompressor in interface CompressionCodec
Returns:
a new compressor for use by this codec

createInputStream

public CompressionInputStream createInputStream(InputStream in)
                                         throws IOException
Create a CompressionInputStream that will read from the given input stream.

Specified by:
createInputStream in interface CompressionCodec
Parameters:
in - the stream to read compressed bytes from
Returns:
a stream to read uncompressed bytes from
Throws:
IOException

createInputStream

public CompressionInputStream createInputStream(InputStream in,
                                                Decompressor decompressor)
                                         throws IOException
Create a CompressionInputStream that will read from the given InputStream with the given Decompressor.

Specified by:
createInputStream in interface CompressionCodec
Parameters:
in - the stream to read compressed bytes from
decompressor - decompressor to use
Returns:
a stream to read uncompressed bytes from
Throws:
IOException

getDecompressorType

public Class<? extends Decompressor> getDecompressorType()
Get the type of Decompressor needed by this CompressionCodec.

Specified by:
getDecompressorType in interface CompressionCodec
Returns:
the type of decompressor needed by this codec.

createDecompressor

public Decompressor createDecompressor()
Create a new Decompressor for use by this CompressionCodec.

Specified by:
createDecompressor in interface CompressionCodec
Returns:
a new decompressor for use by this codec

getDefaultExtension

public String getDefaultExtension()
Get the default filename extension for this kind of compression.

Specified by:
getDefaultExtension in interface CompressionCodec
Returns:
.snappy.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.