Package com.hazelcast.jet.protobuf
Class ProtobufSerializer<T extends com.google.protobuf.GeneratedMessageV3>
java.lang.Object
com.hazelcast.jet.protobuf.ProtobufSerializer<T>
- Type Parameters:
T- the Protocol BuffersGeneratedMessageV3type handled by thisStreamSerializer.
- All Implemented Interfaces:
com.hazelcast.nio.serialization.Serializer,com.hazelcast.nio.serialization.StreamSerializer<T>
public abstract class ProtobufSerializer<T extends com.google.protobuf.GeneratedMessageV3>
extends Object
implements com.hazelcast.nio.serialization.StreamSerializer<T>
Adapts a generated
Google Protocol Buffers v3 serializer class to the Hazelcast
StreamSerializer interface.
To learn how to use this class, visit Jet's Serialization Guide. In brief, you should create a subclass that does nothing else but call this class's protected constructor, and then you can use it in two ways:
-
Register it as a Jet job serializer:
jobConfig.registerSerializer(MyType.class, MyTypeSerializer.class). - Register it with the Jet cluster through a matching implementation of ProtobufSerializerHook
- Since:
- Jet 4.1
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtobufSerializer(Class<T> clazz, int typeId) Called by the subclass to initialize this protobuf serializer. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends com.google.protobuf.GeneratedMessageV3>
ProtobufSerializer<T>A utility method that creates an anonymousProtobufSerializer.intread(com.hazelcast.nio.ObjectDataInput in) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.hazelcast.nio.serialization.Serializer
destroy
-
Constructor Details
-
ProtobufSerializer
Called by the subclass to initialize this protobuf serializer.- Parameters:
clazz-GeneratedMessageV3type handled by this serializertypeId- unique type ID of this serializer
-
-
Method Details
-
getTypeId
public int getTypeId()- Specified by:
getTypeIdin interfacecom.hazelcast.nio.serialization.Serializer
-
write
- Specified by:
writein interfacecom.hazelcast.nio.serialization.StreamSerializer<T extends com.google.protobuf.GeneratedMessageV3>- Throws:
IOException
-
read
- Specified by:
readin interfacecom.hazelcast.nio.serialization.StreamSerializer<T extends com.google.protobuf.GeneratedMessageV3>- Throws:
IOException
-
from
@Nonnull public static <T extends com.google.protobuf.GeneratedMessageV3> ProtobufSerializer<T> from(@Nonnull Class<T> clazz, int typeId) A utility method that creates an anonymousProtobufSerializer.- Type Parameters:
T- the Protocol BuffersGeneratedMessageV3type handled by createdStreamSerializer- Parameters:
clazz-GeneratedMessageV3type of created serializertypeId- unique type id of created serializer
-