Class CoderHelpers


  • public final class CoderHelpers
    extends java.lang.Object
    Serialization utility class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T fromByteArray​(byte[] serialized, org.apache.beam.sdk.coders.Coder<T> coder)
      Utility method for deserializing a byte array using the specified coder.
      static <T> byte[] toByteArray​(T value, org.apache.beam.sdk.coders.Coder<T> coder)
      Utility method for serializing an object using the specified coder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toByteArray

        public static <T> byte[] toByteArray​(T value,
                                             org.apache.beam.sdk.coders.Coder<T> coder)
        Utility method for serializing an object using the specified coder.
        Type Parameters:
        T - type of value that is serialized
        Parameters:
        value - Value to serialize.
        coder - Coder to serialize with.
        Returns:
        Byte array representing serialized object.
      • fromByteArray

        public static <T> T fromByteArray​(byte[] serialized,
                                          org.apache.beam.sdk.coders.Coder<T> coder)
        Utility method for deserializing a byte array using the specified coder.
        Type Parameters:
        T - Type of object to be returned.
        Parameters:
        serialized - bytearray to be deserialized.
        coder - Coder to deserialize with.
        Returns:
        Deserialized object.