Proto2Coder (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

com.google.cloud.dataflow.sdk.coders

Class Proto2Coder<T extends com.google.protobuf.Message>

  • Type Parameters:
    T - the type of elements handled by this coder, must extend Message
    All Implemented Interfaces:
    Coder<T>, Serializable

    Deprecated. 

    @Deprecated
    public class Proto2Coder<T extends com.google.protobuf.Message>
    extends AtomicCoder<T>
    A Coder using Google Protocol Buffers 2 binary format.

    To learn more about Protocol Buffers, visit: https://developers.google.com/protocol-buffers

    To use, specify the Coder type on a PCollection containing Protocol Buffers messages.

     
     PCollection<MyProto.Message> records =
         input.apply(...)
              .setCoder(Proto2Coder.of(MyProto.Message.class));
     
     

    Custom message extensions are also supported, but the coder must be made aware of them explicitly:

     
     PCollection<MyProto.Message> records =
         input.apply(...)
              .setCoder(Proto2Coder.of(MyProto.Message.class)
                  .addExtensionsFrom(MyProto.class));
     
     
    See Also:
    Serialized Form
    • Method Detail

      • coderProvider

        public static CoderProvider coderProvider()
        Deprecated. 
      • of

        public static <T extends com.google.protobuf.Message> Proto2Coder<T> of(Class<T> protoMessageClass)
        Deprecated. 
        Returns a Proto2Coder for the given Protobuf message class.
      • of

        public static <T extends com.google.protobuf.Message> Proto2Coder<T> of(TypeDescriptor<T> protoMessageType)
        Deprecated. 
        Returns a Proto2Coder for the given Protobuf message class.
      • withExtensionsFrom

        public Proto2Coder<T> withExtensionsFrom(Iterable<Class<?>> moreExtensionHosts)
        Deprecated. 
        Produces a Proto2Coder like this one, but with the extensions from the given classes registered.
        Parameters:
        moreExtensionHosts - an iterable of classes that define a static method registerAllExtensions(ExtensionRegistry)
      • encode

        public void encode(T value,
                           OutputStream outStream,
                           Coder.Context context)
                    throws IOException
        Deprecated. 
        Description copied from interface: Coder
        Encodes the given value of type T onto the given output stream in the given context.
        Throws:
        IOException - if writing to the OutputStream fails for some reason
        CoderException - if the value could not be encoded for some reason
      • decode

        public T decode(InputStream inStream,
                        Coder.Context context)
                 throws IOException
        Deprecated. 
        Description copied from interface: Coder
        Decodes a value of type T from the given input stream in the given context. Returns the decoded value.
        Throws:
        IOException - if reading from the InputStream fails for some reason
        CoderException - if the value could not be decoded for some reason
      • equals

        public boolean equals(Object other)
        Deprecated. 
        Description copied from class: StandardCoder
        Overrides:
        equals in class StandardCoder<T extends com.google.protobuf.Message>
        Returns:
        true if the two StandardCoder instances have the same class and equal components.
      • hashCode

        public int hashCode()
        Deprecated. 
        Overrides:
        hashCode in class StandardCoder<T extends com.google.protobuf.Message>
      • getEncodingId

        public String getEncodingId()
        Deprecated. 
        The encoding identifier is designed to support evolution as per the design of Protocol Buffers. In order to use this class effectively, carefully follow the advice in the Protocol Buffers documentation at Updating A Message Type.

        In particular, the encoding identifier is guaranteed to be the same for Proto2Coder instances of the same principal message class, and otherwise distinct. Loaded extensions do not affect the id, nor does it encode the full schema.

        When modifying a message class, here are the broadest guidelines; see the above link for greater detail.

        • Do not change the numeric tags for any fields.
        • Never remove a required field.
        • Only add optional or repeated fields, with sensible defaults.
        • When changing the type of a field, consult the Protocol Buffers documentation to ensure the new and old types are interchangeable.

        Code consuming this message class should be prepared to support all versions of the class until it is certain that no remaining serialized instances exist.

        If backwards incompatible changes must be made, the best recourse is to change the name of your Protocol Buffers message class.

        Specified by:
        getEncodingId in interface Coder<T extends com.google.protobuf.Message>
        Overrides:
        getEncodingId in class StandardCoder<T extends com.google.protobuf.Message>
      • of

        public static <T extends com.google.protobuf.Message> Proto2Coder<T> of(String protoMessageClassName,
                                                                                @Nullable
                                                                                List<String> extensionHostClassNames)
        Deprecated. 
        Constructor for JSON deserialization only.
      • asCloudObject

        public com.google.cloud.dataflow.sdk.util.CloudObject asCloudObject()
        Deprecated. 
        Description copied from interface: Coder
        Returns the CloudObject that represents this Coder.
        Specified by:
        asCloudObject in interface Coder<T extends com.google.protobuf.Message>
        Overrides:
        asCloudObject in class StandardCoder<T extends com.google.protobuf.Message>


Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Dataflow