Class PubSubPositionDeserializer
PubSubPositionWireFormat data into concrete PubSubPosition
instances using a configured PubSubPositionTypeRegistry.
This class offers static access to a default deserializer instance backed by the reserved registry. In most production cases, callers are encouraged to instantiate their own deserializer with a custom registry instead of relying on the default static entry point.
Deserialization involves reading the type ID from the wire format and delegating to the corresponding
PubSubPositionFactory to produce the appropriate position implementation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PubSubPositiondeserializePositionUsingFactoryClassName(PubSubPositionWireFormat wireFormat, String factoryClassName) Deserializes aPubSubPositionWireFormatinto aPubSubPositionusing the provided fully-qualifiedPubSubPositionFactoryclass name.static PubSubPositiondeserializePubSubPosition(byte[] positionWireBytes, String factoryClassName) static PubSubPositiondeserializePubSubPosition(PubSubPositionWireFormat wireFormat, String factoryClassName) static PubSubPositiondeserializePubSubPosition(ByteBuffer positionWireBytes, String factoryClassName) Deserializes aPubSubPositionusing the provided wire format bytes and factory class name.static PubSubPositionWireFormatdeserializeWireFormat(byte[] positionWireFormatBytes) static PubSubPositionWireFormatdeserializeWireFormat(ByteBuffer positionWireFormatBytes) Deserializes aPubSubPositionWireFormatfrom aByteBuffer.toPosition(byte[] positionWireFormatBytes) toPosition(PubSubPositionWireFormat positionWireFormat) Converts a wire format position to a PubSubPositiontoPosition(ByteBuffer positionWireFormatBytes)
-
Field Details
-
DEFAULT_DESERIALIZER
Deprecated.Use explicit instances ofPubSubPositionDeserializerwith a customPubSubPositionTypeRegistryinstead of relying on this static default.Note: The following default instance is only for convenience purposes until we've updated all the code to use pass the registry and resolver explicitly.
-
-
Constructor Details
-
PubSubPositionDeserializer
-
-
Method Details
-
toPosition
Converts a wire format position to a PubSubPosition- Parameters:
positionWireFormat- the wire format position- Returns:
- concrete position object represented by the wire format
-
toPosition
-
toPosition
-
deserializePositionUsingFactoryClassName
public static PubSubPosition deserializePositionUsingFactoryClassName(PubSubPositionWireFormat wireFormat, String factoryClassName) Deserializes aPubSubPositionWireFormatinto aPubSubPositionusing the provided fully-qualifiedPubSubPositionFactoryclass name.This method is intended for use cases where the factory class name is explicitly stored alongside the wire format, such as in repush checkpointing or change capture consumers. It bypasses the usual deserialization path involving
PubSubPositionDeserializerandPubSubPositionTypeRegistry.Note: This method should NOT be used within Venice servers or controllers, where factory mappings are dynamically registered and accessed via type ID. Use this only when the factory class name is stored and reflection is the only viable deserialization strategy.
The factory class must implement
PubSubPositionFactoryand provide a constructor with a singleintargument representing the position type ID.- Parameters:
wireFormat- the wire format of the positionfactoryClassName- the fully-qualified class name of the factory to use for deserialization- Returns:
- a
PubSubPositioninstance deserialized from the wire format - Throws:
VeniceException- if instantiation or deserialization fails
-
deserializePubSubPosition
public static PubSubPosition deserializePubSubPosition(ByteBuffer positionWireBytes, String factoryClassName) Deserializes aPubSubPositionusing the provided wire format bytes and factory class name.This helper is intended for use cases where the factory class name is explicitly stored alongside the position wire format bytes, such as in repush checkpoints or change capture consumers.
It should not be used in Venice servers or controllers where position deserialization is handled via
PubSubPositionDeserializerandPubSubPositionTypeRegistrybased on type IDs.- Parameters:
positionWireBytes- the serialized wire format bytes in aByteBufferfactoryClassName- the fully-qualified class name of the factory used to deserialize the position- Returns:
- the deserialized
PubSubPosition - Throws:
RuntimeException- if deserialization or factory instantiation fails
-
deserializePubSubPosition
public static PubSubPosition deserializePubSubPosition(byte[] positionWireBytes, String factoryClassName) -
deserializePubSubPosition
public static PubSubPosition deserializePubSubPosition(PubSubPositionWireFormat wireFormat, String factoryClassName) -
deserializeWireFormat
Deserializes aPubSubPositionWireFormatfrom aByteBuffer.This method extracts a byte array from the given
ByteBufferand usesPubSubPosition.PUBSUB_POSITION_WIRE_FORMAT_SERIALIZER} to decode it into aPubSubPositionWireFormatinstance.This is typically used when reconstructing position metadata stored in serialized wire format, such as in checkpointing, audit logs, or administrative tooling.
- Parameters:
positionWireFormatBytes- the wire format bytes wrapped in aByteBuffer- Returns:
- the deserialized
PubSubPositionWireFormat - Throws:
RuntimeException- if deserialization fails
-
deserializeWireFormat
-
PubSubPositionDeserializerwith a customPubSubPositionTypeRegistryinstead of relying on this static default.