Avro C#
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Avro.File.Codec Class Referenceabstract

Base class for Avro-supported compression codecs for data files. Note that Codec objects may maintain internal state (e.g. buffers) and are not thread safe. More...

Inheritance diagram for Avro.File.Codec:
Avro.File.DeflateCodec Avro.File.NullCodec

Public Types

enum  Type {
  Type.Deflate, Type.Null, Type.Snappy, Type.BZip2,
  Type.XZ, Type.Zstandard
}
 Codec types. More...
 

Public Member Functions

abstract byte[] Compress (byte[] uncompressedData)
 Compress data using implemented codec. More...
 
abstract void Compress (MemoryStream inputStream, MemoryStream outputStream)
 Compress data using implemented codec. More...
 
virtual byte[] Decompress (byte[] compressedData)
 Decompress data using implemented codec. More...
 
abstract byte[] Decompress (byte[] compressedData, int length)
 Decompress data using implemented codec More...
 
abstract string GetName ()
 Name of this codec type. More...
 
abstract override bool Equals (object other)
 Codecs must implement an equals() method. More...
 
abstract override int GetHashCode ()
 Codecs must implement a HashCode() method that is consistent with Equals. More...
 
delegate Codec CodecResolver (string codecMetaString)
 Represents a function capable of resolving a codec string with a matching codec implementation a reader can use to decompress data. More...
 
override string ToString ()
 Returns name of codec. More...
 

Static Public Member Functions

static void RegisterResolver (CodecResolver resolver)
 Registers a function that will attempt to resolve a codec identifying string with a matching codec implementation when reading compressed Avro data. More...
 
static Codec CreateCodec (Type codecType)
 Factory method to return child codec instance based on Codec.Type. More...
 
static Codec CreateCodecFromString (string codecType)
 Factory method to return child codec instance based on string type. More...
 

Detailed Description

Base class for Avro-supported compression codecs for data files. Note that Codec objects may maintain internal state (e.g. buffers) and are not thread safe.

Member Enumeration Documentation

◆ Type

enum Avro.File.Codec.Type
strong

Codec types.

Enumerator
Deflate 

Codec type that implements the "deflate" compression algorithm.

Null 

Codec that does not perform any compression.

Snappy 

Codec type that implements the "Snappy" compression algorithm.

BZip2 

Codec type that implements the "BZip2" compression algorithm.

XZ 

Codec type that implements the "XZ" compression algorithm.

Zstandard 

Codec type that implements the "Zstandard" compression algorithm.

Member Function Documentation

◆ CodecResolver()

delegate Codec Avro.File.Codec.CodecResolver ( string  codecMetaString)

Represents a function capable of resolving a codec string with a matching codec implementation a reader can use to decompress data.

Parameters
codecMetaStringThe codec string

◆ Compress() [1/2]

abstract byte [] Avro.File.Codec.Compress ( byte[]  uncompressedData)
pure virtual

Compress data using implemented codec.

Parameters
uncompressedDataThe uncompressed data.
Returns
byte array.

Implemented in Avro.File.NullCodec, and Avro.File.DeflateCodec.

◆ Compress() [2/2]

abstract void Avro.File.Codec.Compress ( MemoryStream  inputStream,
MemoryStream  outputStream 
)
pure virtual

Compress data using implemented codec.

Parameters
inputStreamThe stream which contains the data to be compressed.
outputStreamA reusable stream which will hold the compressed data. That stream should be empty.

Implemented in Avro.File.DeflateCodec, and Avro.File.NullCodec.

◆ CreateCodec()

static Codec Avro.File.Codec.CreateCodec ( Type  codecType)
inlinestatic

Factory method to return child codec instance based on Codec.Type.

Parameters
codecTypeType of the codec.
Returns
Codec based on type.

◆ CreateCodecFromString()

static Codec Avro.File.Codec.CreateCodecFromString ( string  codecType)
inlinestatic

Factory method to return child codec instance based on string type.

Parameters
codecTypeType of the codec.
Returns
Codec based on type.

◆ Decompress() [1/2]

virtual byte [] Avro.File.Codec.Decompress ( byte[]  compressedData)
inlinevirtual

Decompress data using implemented codec.

Parameters
compressedDataThe buffer holding data to decompress.
Returns
A byte array holding the decompressed data.

◆ Decompress() [2/2]

abstract byte [] Avro.File.Codec.Decompress ( byte[]  compressedData,
int  length 
)
pure virtual

Decompress data using implemented codec

Parameters
compressedDataThe buffer holding data to decompress.
lengthThe actual length of bytes to decompress from the buffer.
Returns
A byte array holding the decompressed data.

Implemented in Avro.File.DeflateCodec, and Avro.File.NullCodec.

◆ Equals()

abstract override bool Avro.File.Codec.Equals ( object  other)
pure virtual

Codecs must implement an equals() method.

Parameters
otherThe object to compare with this instance.
Returns
true if the specified object is equal to this instance; otherwise, false.

Implemented in Avro.File.DeflateCodec, and Avro.File.NullCodec.

◆ GetHashCode()

abstract override int Avro.File.Codec.GetHashCode ( )
pure virtual

Codecs must implement a HashCode() method that is consistent with Equals.

Returns
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Implemented in Avro.File.DeflateCodec, and Avro.File.NullCodec.

◆ GetName()

abstract string Avro.File.Codec.GetName ( )
pure virtual

Name of this codec type.

Returns
The codec name.

Implemented in Avro.File.DeflateCodec, and Avro.File.NullCodec.

◆ RegisterResolver()

static void Avro.File.Codec.RegisterResolver ( CodecResolver  resolver)
inlinestatic

Registers a function that will attempt to resolve a codec identifying string with a matching codec implementation when reading compressed Avro data.

Parameters
resolverA function that is able to find a codec implementation for a given codec string

◆ ToString()

override string Avro.File.Codec.ToString ( )
inline

Returns name of codec.

Returns
A string that represents this instance.

The documentation for this class was generated from the following file: