Class PubSubPositionFactory

java.lang.Object
com.linkedin.venice.pubsub.PubSubPositionFactory
Direct Known Subclasses:
ApacheKafkaOffsetPositionFactory, EarliestPositionFactory, LatestPositionFactory

public abstract class PubSubPositionFactory extends Object
A factory interface for creating PubSubPosition instances and resolving their associated class names.

Each implementation is tied to a unique position type ID and is responsible for:

Factories are used during deserialization to map a type ID to the appropriate PubSubPosition implementation.

  • Constructor Details

    • PubSubPositionFactory

      public PubSubPositionFactory(int positionTypeId)
      Constructs a factory with the given position type ID.
      Parameters:
      positionTypeId - the unique integer identifier for the position type
  • Method Details

    • createFromWireFormat

      public PubSubPosition createFromWireFormat(PubSubPositionWireFormat positionWireFormat)
      Creates a PubSubPosition instance by deserializing the provided PubSubPositionWireFormat.

      This method validates that the type ID in the wire format matches the expected type ID for this factory. If the type ID does not match, an exception is thrown to prevent incorrect deserialization.

      Internally, this delegates to createFromByteBuffer(ByteBuffer) to perform the actual decoding.

      Parameters:
      positionWireFormat - the wire format containing the type ID and raw encoded bytes
      Returns:
      a new PubSubPosition instance reconstructed from the wire format
      Throws:
      VeniceException - if the type ID does not match the factory's expected type
    • createFromByteBuffer

      public abstract PubSubPosition createFromByteBuffer(ByteBuffer buffer)
      Deserializes a PubSubPosition from the given byte buffer.
      Parameters:
      buffer - the byte buffer containing the serialized position
      Returns:
      a new PubSubPosition instance
    • getPubSubPositionClassName

      public abstract String getPubSubPositionClassName()
      Returns the fully qualified class name of the PubSubPosition implementation handled by this factory.
      Returns:
      the fully qualified class name of the associated position class
    • getPositionTypeId

      public int getPositionTypeId()
      Returns the unique position type ID associated with this factory.
      Returns:
      the integer type ID