org.apache.avro.file

## Class Codec

- java.lang.Object
- - org.apache.avro.file.Codec

- Direct Known Subclasses:
    BZip2Codec, DeflateCodec, SnappyCodec, XZCodec, ZstandardCodec

      public abstract class Codec
      extends Object

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Codec()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract ByteBuffer` | `compress(ByteBuffer uncompressedData)` Compresses the input data
    `protected static int` | `computeOffset(ByteBuffer data)`
    `abstract ByteBuffer` | `decompress(ByteBuffer compressedData)` Decompress the data
    `abstract boolean` | `equals(Object other)` Codecs must implement an equals() method.
    `abstract String` | `getName()` Name of the codec; written to the file's metadata.
    `abstract int` | `hashCode()` Codecs must implement a hashCode() method that is consistent with equals().
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### Codec

          public Codec()

  - ### Method Detail

    - #### getName

          public abstract String getName()

      Name of the codec; written to the file's metadata.

    - #### compress

          public abstract ByteBuffer compress(ByteBuffer uncompressedData)
                                       throws IOException

      Compresses the input data
      Throws:
        `IOException`

    - #### decompress

          public abstract ByteBuffer decompress(ByteBuffer compressedData)
                                         throws IOException

      Decompress the data
      Throws:
        `IOException`

    - #### equals

          public abstract boolean equals(Object other)

      Codecs must implement an equals() method. Two codecs, A and B are equal if: the result of A and B decompressing content compressed by A is the same AND the result of A and B decompressing content compressed by B is the same
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public abstract int hashCode()

      Codecs must implement a hashCode() method that is consistent with equals().
      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### computeOffset

          protected static int computeOffset(ByteBuffer data)

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.