Top Description Fields Constructors Methods
org.apache.avro.file

public abstract Class CodecFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.avro.file.DeflateCodec.Option, org.apache.avro.file.NullCodec.Option, org.apache.avro.file.SnappyCodec.Option, org.apache.avro.file.XZCodec.Option, org.apache.avro.file.ZstandardCodec.Option, org.apache.avro.file.BZip2Codec.Option
Imports
java.util.HashMap, .Map, java.util.zip.Deflater, org.apache.avro.AvroRuntimeException, org.slf4j.Logger, .LoggerFactory

Encapsulates the ability to specify and configure a compression codec. Currently there are three codecs registered by default: New and custom codecs can be registered using addCodec(String, CodecFactory).

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final boolean
public static final int
private static final Logger
private static final Map<String, CodecFactory>
REGISTERED

Mapping of string names (stored as metas) and codecs.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static CodecFactory
addCodec(String name, CodecFactory c)

Adds a new codec implementation.

public static CodecFactory
bzip2Codec()

bzip2 codec.

protected abstract Codec
createInstance()

Creates internal Codec.

public static CodecFactory
deflateCodec(int compressionLevel)

Deflate codec, with specific compression.

public static CodecFactory
fromString(String s)

Maps a codec name into a CodecFactory.

public static CodecFactory
nullCodec()

Null codec, for no compression.

public static CodecFactory
snappyCodec()

Snappy codec.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public static CodecFactory
xzCodec(int compressionLevel)

XZ codec, with specific compression.

public static CodecFactory
zstandardCodec(int
The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.
level
)

zstandard codec, with specific compression level.

public static CodecFactory
zstandardCodec(int
The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.
level
,
boolean
if true, will include a checksum with each data block
useChecksum
)

zstandard codec, with specific compression level.

public static CodecFactory
zstandardCodec(int
The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.
level
,
boolean
if true, will include a checksum with each data block
useChecksum
,
boolean
if true, will use recycling buffer pool
useBufferPool
)

zstandard codec, with specific compression level, checksum, and bufferPool

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_DEFLATE_LEVELback to summary
public static final int DEFAULT_DEFLATE_LEVEL
DEFAULT_XZ_LEVELback to summary
public static final int DEFAULT_XZ_LEVEL
DEFAULT_ZSTANDARD_BUFFERPOOLback to summary
public static final boolean DEFAULT_ZSTANDARD_BUFFERPOOL
DEFAULT_ZSTANDARD_LEVELback to summary
public static final int DEFAULT_ZSTANDARD_LEVEL
LOGback to summary
private static final Logger LOG
REGISTEREDback to summary
private static final Map<String, CodecFactory> REGISTERED

Mapping of string names (stored as metas) and codecs. Note that currently options (like compression level) are not recoverable.

Constructor Detail

CodecFactoryback to summary
public CodecFactory()

Method Detail

addCodecback to summary
public static CodecFactory addCodec(String name, CodecFactory c)

Adds a new codec implementation. If name already had a codec associated with it, returns the previous codec.

bzip2Codecback to summary
public static CodecFactory bzip2Codec()

bzip2 codec.

createInstanceback to summary
protected abstract Codec createInstance()

Creates internal Codec.

deflateCodecback to summary
public static CodecFactory deflateCodec(int compressionLevel)

Deflate codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.

fromStringback to summary
public static CodecFactory fromString(String s)

Maps a codec name into a CodecFactory. Currently there are six codecs registered by default:

  • null
  • deflate
  • snappy
  • bzip2
  • xz
  • zstandard
nullCodecback to summary
public static CodecFactory nullCodec()

Null codec, for no compression.

snappyCodecback to summary
public static CodecFactory snappyCodec()

Snappy codec.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
xzCodecback to summary
public static CodecFactory xzCodec(int compressionLevel)

XZ codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.

zstandardCodecback to summary
public static CodecFactory zstandardCodec(int level)

zstandard codec, with specific compression level.

Parameters
level:int

The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.

zstandardCodecback to summary
public static CodecFactory zstandardCodec(int level, boolean useChecksum)

zstandard codec, with specific compression level.

Parameters
level:int

The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.

useChecksum:boolean

if true, will include a checksum with each data block

zstandardCodecback to summary
public static CodecFactory zstandardCodec(int level, boolean useChecksum, boolean useBufferPool)

zstandard codec, with specific compression level, checksum, and bufferPool

Parameters
level:int

The compression level should be between -5 and 22, inclusive. Negative levels are 'fast' modes akin to lz4 or snappy, levels above 9 are generally for archival purposes, and levels above 18 use a lot of memory.

useChecksum:boolean

if true, will include a checksum with each data block

useBufferPool:boolean

if true, will use recycling buffer pool