Package com.linkedin.davinci.consumer
Class VeniceChangeCoordinate
java.lang.Object
com.linkedin.davinci.consumer.VeniceChangeCoordinate
- All Implemented Interfaces:
Externalizable
,Serializable
This class represents a change coordinate in Venice. It contains the topic name, partition number, and
the pubsub position.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
VeniceChangeCoordinate
(String topic, PubSubPosition pubSubPosition, Integer partition) -
Method Summary
Modifier and TypeMethodDescriptionint
static String
convertVeniceChangeCoordinateToStringAndEncode
(VeniceChangeCoordinate veniceChangeCoordinate) static VeniceChangeCoordinate
decodeStringAndConvertToVeniceChangeCoordinate
(PubSubPositionDeserializer deserializer, String offsetString) boolean
protected PubSubPosition
protected String
getTopic()
int
hashCode()
void
Deserializes VeniceChangeCoordinate while supporting both legacy (v1) and newer (v2+) formats.protected void
setPubSubPositionDeserializer
(PubSubPositionDeserializer pubSubPositionDeserializer) toString()
void
Serializes the VeniceChangeCoordinate in a backward-compatible format.
-
Constructor Details
-
VeniceChangeCoordinate
public VeniceChangeCoordinate() -
VeniceChangeCoordinate
-
-
Method Details
-
writeExternal
Serializes the VeniceChangeCoordinate in a backward-compatible format.The serialization format is structured as follows:
- Core fields: topic, partition, pubSubPositionWireFormat
- Version tag: a UTF string that identifies the version of the serialized data
- 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 interfaceExternalizable
- Parameters:
out
- the output stream to write to- Throws:
IOException
- if writing fails
-
readExternal
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 interfaceExternalizable
- Parameters:
in
- the input stream to read from- Throws:
IOException
- if an I/O error occursVeniceException
- if the class of a serialized object cannot be foundClassNotFoundException
-
getPartition
-
getStoreName
-
comparePosition
- 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
-
getPosition
-
setPubSubPositionDeserializer
-
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
-
equals
-
hashCode
public int hashCode()
-