Class VeniceChangeCoordinate

java.lang.Object
com.linkedin.davinci.consumer.VeniceChangeCoordinate
All Implemented Interfaces:
Externalizable, Serializable

public class VeniceChangeCoordinate extends Object implements Externalizable
This class represents a change coordinate in Venice. It contains the topic name, partition number, and the pubsub position.
See Also:
  • Constructor Details

    • VeniceChangeCoordinate

      public VeniceChangeCoordinate()
    • VeniceChangeCoordinate

      protected VeniceChangeCoordinate(String topic, PubSubPosition pubSubPosition, Integer partition)
  • Method Details

    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Serializes the VeniceChangeCoordinate in a backward-compatible format.

      The serialization format is structured as follows:

      1. Core fields: topic, partition, pubSubPositionWireFormat
      2. Version tag: a UTF string that identifies the version of the serialized data
      3. Version-specific fields: additional fields added in newer versions

      This format ensures that older readers (pre-v2) can still deserialize the first three fields, while newer readers will detect and parse the version tag and the extra fields.

      Specified by:
      writeExternal in interface Externalizable
      Parameters:
      out - the output stream to write to
      Throws:
      IOException - if writing fails
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Deserializes VeniceChangeCoordinate while supporting both legacy (v1) and newer (v2+) formats.

      The method first reads the core fields (topic, partition, position wire format), which are common across versions. It then attempts to read a version tag.

      • If the version tag is present and recognized, version-specific fields are read accordingly.
      • If the tag is missing or reading fails, the method falls back to v1 format.

      This approach is robust against partial data and ensures forward and backward compatibility.

      Specified by:
      readExternal in interface Externalizable
      Parameters:
      in - the input stream to read from
      Throws:
      IOException - if an I/O error occurs
      VeniceException - if the class of a serialized object cannot be found
      ClassNotFoundException
    • getPartition

      public Integer getPartition()
    • getStoreName

      public String getStoreName()
    • comparePosition

      public int comparePosition(VeniceChangeCoordinate other)
      Parameters:
      other - the other position to compare to
      Returns:
      returns 0 if the positions are equal, -1 if this position is less than the other position, and 1 if this position is greater than the other position
    • getTopic

      protected String getTopic()
    • getPosition

      protected PubSubPosition getPosition()
    • setPubSubPositionDeserializer

      protected void setPubSubPositionDeserializer(PubSubPositionDeserializer pubSubPositionDeserializer)
    • convertVeniceChangeCoordinateToStringAndEncode

      public static String convertVeniceChangeCoordinateToStringAndEncode(VeniceChangeCoordinate veniceChangeCoordinate) throws IOException
      Throws:
      IOException
    • decodeStringAndConvertToVeniceChangeCoordinate

      public static VeniceChangeCoordinate decodeStringAndConvertToVeniceChangeCoordinate(PubSubPositionDeserializer deserializer, String offsetString) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object