Google Cloud Dataflow SDK for Java, version 1.9.1
Class Proto2Coder<T extends com.google.protobuf.Message>
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.coders.StandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.AtomicCoder<T>
-
- com.google.cloud.dataflow.sdk.coders.Proto2Coder<T>
-
- Type Parameters:
T
- the type of elements handled by this coder, must extendMessage
- All Implemented Interfaces:
- Coder<T>, Serializable
Deprecated.UseProtoCoder
.
@Deprecated public class Proto2Coder<T extends com.google.protobuf.Message> extends AtomicCoder<T>
ACoder
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.cloud.dataflow.sdk.coders.Coder
Coder.Context, Coder.NonDeterministicException
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description Proto2Coder<T>
addExtensionsFrom(Class<?>... extensionHosts)
Deprecated.Proto2Coder<T>
addExtensionsFrom(Iterable<Class<?>> extensionHosts)
Deprecated.com.google.cloud.dataflow.sdk.util.CloudObject
asCloudObject()
Deprecated.Returns theCloudObject
that represents thisCoder
.static CoderProvider
coderProvider()
Deprecated.T
decode(InputStream inStream, Coder.Context context)
Deprecated.Decodes a value of typeT
from the given input stream in the given context.void
encode(T value, OutputStream outStream, Coder.Context context)
Deprecated.Encodes the given value of typeT
onto the given output stream in the given context.boolean
equals(Object other)
Deprecated.String
getEncodingId()
Deprecated.The encoding identifier is designed to support evolution as per the design of Protocol Buffers.int
hashCode()
Deprecated.static <T extends com.google.protobuf.Message>
Proto2Coder<T>of(Class<T> protoMessageClass)
Deprecated.Returns aProto2Coder
for the given Protobuf message class.static <T extends com.google.protobuf.Message>
Proto2Coder<T>of(String protoMessageClassName, List<String> extensionHostClassNames)
Deprecated.Constructor for JSON deserialization only.static <T extends com.google.protobuf.Message>
Proto2Coder<T>of(TypeDescriptor<T> protoMessageType)
Deprecated.Returns aProto2Coder
for the given Protobuf message class.Proto2Coder<T>
withExtensionsFrom(Class<?>... extensionHosts)
Deprecated.Proto2Coder<T>
withExtensionsFrom(Iterable<Class<?>> moreExtensionHosts)
Deprecated.Produces aProto2Coder
like this one, but with the extensions from the given classes registered.-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.AtomicCoder
getCoderArguments, getInstanceComponents
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.DeterministicStandardCoder
verifyDeterministic
-
Methods inherited from class com.google.cloud.dataflow.sdk.coders.StandardCoder
consistentWithEquals, getAllowedEncodings, getComponents, getEncodedElementByteSize, isRegisterByteSizeObserverCheap, registerByteSizeObserver, structuralValue, toString, verifyDeterministic, verifyDeterministic
-
-
-
-
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 aProto2Coder
for the given Protobuf message class.
-
of
public static <T extends com.google.protobuf.Message> Proto2Coder<T> of(TypeDescriptor<T> protoMessageType)
Deprecated.Returns aProto2Coder
for the given Protobuf message class.
-
withExtensionsFrom
public Proto2Coder<T> withExtensionsFrom(Iterable<Class<?>> moreExtensionHosts)
Deprecated.Produces aProto2Coder
like this one, but with the extensions from the given classes registered.- Parameters:
moreExtensionHosts
- an iterable of classes that define a static methodregisterAllExtensions(ExtensionRegistry)
-
withExtensionsFrom
public Proto2Coder<T> withExtensionsFrom(Class<?>... extensionHosts)
Deprecated.
-
addExtensionsFrom
@Deprecated public Proto2Coder<T> addExtensionsFrom(Class<?>... extensionHosts)
Deprecated. usewithExtensionsFrom(java.lang.Iterable<java.lang.Class<?>>)
Adds custom Protobuf extensions to the coder. Returnsthis
for method chaining.- Parameters:
extensionHosts
- must be a class that defines a static method nameregisterAllExtensions
-
addExtensionsFrom
@Deprecated public Proto2Coder<T> addExtensionsFrom(Iterable<Class<?>> extensionHosts)
Deprecated. usewithExtensionsFrom(java.lang.Iterable<java.lang.Class<?>>)
Adds custom Protobuf extensions to the coder. Returnsthis
for method chaining.- Parameters:
extensionHosts
- must be a class that defines a static method nameregisterAllExtensions
-
encode
public void encode(T value, OutputStream outStream, Coder.Context context) throws IOException
Deprecated.Description copied from interface:Coder
Encodes the given value of typeT
onto the given output stream in the given context.- Throws:
IOException
- if writing to theOutputStream
fails for some reasonCoderException
- 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 typeT
from the given input stream in the given context. Returns the decoded value.- Throws:
IOException
- if reading from theInputStream
fails for some reasonCoderException
- 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 classStandardCoder<T extends com.google.protobuf.Message>
- Returns:
true
if the twoStandardCoder
instances have the same class and equal components.
-
hashCode
public int hashCode()
Deprecated.- Overrides:
hashCode
in classStandardCoder<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
orrepeated
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 interfaceCoder<T extends com.google.protobuf.Message>
- Overrides:
getEncodingId
in classStandardCoder<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 theCloudObject
that represents thisCoder
.- Specified by:
asCloudObject
in interfaceCoder<T extends com.google.protobuf.Message>
- Overrides:
asCloudObject
in classStandardCoder<T extends com.google.protobuf.Message>
-
-