Package org.apache.avro.file

# Class CodecFactory

java.lang.Object
org.apache.avro.file.CodecFactory

public abstract class CodecFactory extends Object
Encapsulates the ability to specify and configure a compression codec. Currently there are five codecs registered by default:

- `null`
- `deflate`
- `snappy`
- `bzip2`
- `xz`
- `zstandard`

New and custom codecs can be registered using `addCodec(String, CodecFactory)`.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_DEFLATE_LEVEL`
`static final int`
`DEFAULT_XZ_LEVEL`
`static final boolean`
`DEFAULT_ZSTANDARD_BUFFERPOOL`
`static final int`
`DEFAULT_ZSTANDARD_LEVEL`

## Constructor Summary

Constructors
Constructor
Description
`CodecFactory()`

## Method Summary

Modifier and Type
Method
Description
`static CodecFactory`
`addCodec(String name, CodecFactory c)`
Adds a new codec implementation.
`static CodecFactory`
`bzip2Codec()`
bzip2 codec.
`protected abstract Codec`
`createInstance()`
Creates internal Codec.
`static CodecFactory`
`deflateCodec(int compressionLevel)`
Deflate codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.
`static CodecFactory`
`fromString(String s)`
Maps a codec name into a CodecFactory.
`static CodecFactory`
`nullCodec()`
Null codec, for no compression.
`static CodecFactory`
`snappyCodec()`
Snappy codec.
`String`
`toString()`
`static CodecFactory`
`xzCodec(int compressionLevel)`
XZ codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.
`static CodecFactory`
`zstandardCodec(int level)`
zstandard codec, with specific compression level.
`static CodecFactory`
`zstandardCodec(int level, boolean useChecksum)`
zstandard codec, with specific compression level.
`static CodecFactory`
`zstandardCodec(int level, boolean useChecksum, boolean useBufferPool)`
zstandard codec, with specific compression level, checksum, and bufferPool

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### DEFAULT_DEFLATE_LEVEL

public static final int DEFAULT_DEFLATE_LEVEL

See Also:
  - Constant Field Values

### DEFAULT_XZ_LEVEL

public static final int DEFAULT_XZ_LEVEL

See Also:
  - Constant Field Values

### DEFAULT_ZSTANDARD_LEVEL

public static final int DEFAULT_ZSTANDARD_LEVEL

See Also:
  - Constant Field Values

### DEFAULT_ZSTANDARD_BUFFERPOOL

public static final boolean DEFAULT_ZSTANDARD_BUFFERPOOL

See Also:
  - Constant Field Values

## Constructor Details

### CodecFactory

public CodecFactory()

## Method Details

### nullCodec

public static CodecFactory nullCodec()
Null codec, for no compression.

### deflateCodec

public static CodecFactory deflateCodec(int compressionLevel)
Deflate codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.

### xzCodec

public static CodecFactory xzCodec(int compressionLevel)
XZ codec, with specific compression. compressionLevel should be between 1 and 9, inclusive.

### snappyCodec

public static CodecFactory snappyCodec()
Snappy codec.

### bzip2Codec

public static CodecFactory bzip2Codec()
bzip2 codec.

### zstandardCodec

public static CodecFactory zstandardCodec(int level)
zstandard codec, with specific compression level.

Parameters:
  `level` - 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.

### zstandardCodec

public static CodecFactory zstandardCodec(int level, boolean useChecksum)
zstandard codec, with specific compression level.

Parameters:
  `level` - 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` - if true, will include a checksum with each data block

### zstandardCodec

public static CodecFactory zstandardCodec(int level, boolean useChecksum, boolean useBufferPool)
zstandard codec, with specific compression level, checksum, and bufferPool

Parameters:
  `level` - 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` - if true, will include a checksum with each data block
  `useBufferPool` - if true, will use recycling buffer pool

### createInstance

protected abstract Codec createInstance()
Creates internal Codec.

### fromString

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`

### addCodec

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.

### toString

public String toString()

Overrides:
  `toString` in class `Object`