Class KryoCoder<T>

  • Type Parameters:
    T - type of element coder can handle
    All Implemented Interfaces:
    java.io.Serializable

    public class KryoCoder<T>
    extends org.apache.beam.sdk.coders.CustomCoder<T>
    Coder using Kryo as (de)serialization mechanism. See KryoCoderProvider to get more details about usage.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.beam.sdk.coders.Coder

        org.apache.beam.sdk.coders.Coder.Context, org.apache.beam.sdk.coders.Coder.NonDeterministicException
    • Method Detail

      • of

        public static <T> KryoCoder<T> of()
        Create a new KryoCoder with default KryoOptions.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Returns:
        Newly created a KryoCoder
      • of

        public static <T> KryoCoder<T> of​(KryoRegistrar... registrars)
        Create a new KryoCoder with default KryoOptions.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Parameters:
        registrars - KryoRegistrars which are used to register classes with underlying kryo instance
        Returns:
        Newly created a KryoCoder
      • of

        public static <T> KryoCoder<T> of​(java.util.List<KryoRegistrar> registrars)
        Create a new KryoCoder with default KryoOptions.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Parameters:
        registrars - KryoRegistrars which are used to register classes with underlying kryo instance
        Returns:
        Newly created a KryoCoder
      • of

        public static <T> KryoCoder<T> of​(org.apache.beam.sdk.options.PipelineOptions pipelineOptions)
        Create a new KryoCoder.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Parameters:
        pipelineOptions - Options used for coder setup. See KryoOptions for more details.
        Returns:
        Newly created a KryoCoder
      • of

        public static <T> KryoCoder<T> of​(org.apache.beam.sdk.options.PipelineOptions pipelineOptions,
                                          KryoRegistrar... registrars)
        Create a new KryoCoder.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Parameters:
        pipelineOptions - Options used for coder setup. See KryoOptions for more details.
        registrars - KryoRegistrars which are used to register classes with underlying kryo instance
        Returns:
        Newly created a KryoCoder
      • of

        public static <T> KryoCoder<T> of​(org.apache.beam.sdk.options.PipelineOptions pipelineOptions,
                                          java.util.List<KryoRegistrar> registrars)
        Create a new KryoCoder.
        Type Parameters:
        T - type of element this class should decode/encode Kryo instance used by returned KryoCoder
        Parameters:
        pipelineOptions - Options used for coder setup. See KryoOptions for more details.
        registrars - KryoRegistrars which are used to register classes with underlying kryo instance
        Returns:
        Newly created a KryoCoder
      • encode

        public void encode​(T value,
                           java.io.OutputStream outStream)
                    throws java.io.IOException
        Specified by:
        encode in class org.apache.beam.sdk.coders.Coder<T>
        Throws:
        java.io.IOException
      • decode

        public T decode​(java.io.InputStream inStream)
                 throws java.io.IOException
        Specified by:
        decode in class org.apache.beam.sdk.coders.Coder<T>
        Throws:
        java.io.IOException
      • verifyDeterministic

        public void verifyDeterministic()
                                 throws org.apache.beam.sdk.coders.Coder.NonDeterministicException
        Overrides:
        verifyDeterministic in class org.apache.beam.sdk.coders.CustomCoder<T>
        Throws:
        org.apache.beam.sdk.coders.Coder.NonDeterministicException
      • withRegistrar

        public KryoCoder<T> withRegistrar​(KryoRegistrar registrar)
        Create a new KryoCoder instance with the user provided registrar.
        Parameters:
        registrar - registrar to append to list of already registered registrars.
        Returns:
        new kryo coder
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(@Nullable java.lang.Object other)
        Overrides:
        equals in class java.lang.Object