Class WritableCoder<T extends org.apache.hadoop.io.Writable>

  • Type Parameters:
    T - the type of elements handled by this coder.
    All Implemented Interfaces:
    java.io.Serializable

    public class WritableCoder<T extends org.apache.hadoop.io.Writable>
    extends org.apache.beam.sdk.coders.CustomCoder<T>
    A WritableCoder is a Coder for a Java class that implements Writable.

    To use, specify the coder type on a PCollection:

    
     PCollection<MyRecord> records =
         foo.apply(...).setCoder(WritableCoder.of(MyRecord.class));
     
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  WritableCoder.WritableCoderProviderRegistrar
      A CoderProviderRegistrar which registers a CoderProvider which can handle writable types.
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      WritableCoder​(java.lang.Class<T> type)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T decode​(java.io.InputStream inStream)  
      void encode​(T value, java.io.OutputStream outStream)  
      boolean equals​(@Nullable java.lang.Object other)  
      java.util.List<org.apache.beam.sdk.coders.Coder<?>> getCoderArguments()  
      static org.apache.beam.sdk.coders.CoderProvider getCoderProvider()
      Returns a CoderProvider which uses the WritableCoder for Hadoop writable types.
      int hashCode()  
      static <T extends org.apache.hadoop.io.Writable>
      WritableCoder<T>
      of​(java.lang.Class<T> clazz)
      Returns a WritableCoder instance for the provided element class.
      void verifyDeterministic()  
      • Methods inherited from class org.apache.beam.sdk.coders.Coder

        consistentWithEquals, decode, encode, getEncodedElementByteSize, getEncodedElementByteSizeUsingCoder, getEncodedTypeDescriptor, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, verifyDeterministic, verifyDeterministic
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WritableCoder

        public WritableCoder​(java.lang.Class<T> type)
    • Method Detail

      • of

        public static <T extends org.apache.hadoop.io.Writable> WritableCoder<T> of​(java.lang.Class<T> clazz)
        Returns a WritableCoder instance for the provided element class.
        Type Parameters:
        T - the element type
      • 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 extends org.apache.hadoop.io.Writable>
        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 extends org.apache.hadoop.io.Writable>
        Throws:
        java.io.IOException
      • getCoderArguments

        public java.util.List<org.apache.beam.sdk.coders.Coder<?>> getCoderArguments()
        Overrides:
        getCoderArguments in class org.apache.beam.sdk.coders.CustomCoder<T extends org.apache.hadoop.io.Writable>
      • verifyDeterministic

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

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

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

        public static org.apache.beam.sdk.coders.CoderProvider getCoderProvider()
        Returns a CoderProvider which uses the WritableCoder for Hadoop writable types.

        This method is invoked reflectively from DefaultCoder.