Package com.linkedin.venice.message
Class KafkaKey
java.lang.Object
com.linkedin.venice.message.KafkaKey
- All Implemented Interfaces:
Measurable
Class which stores the components of a Kafka Key, and is the format specified in the
KafkaKeySerializer
.-
Field Summary
-
Constructor Summary
ConstructorDescriptionKafkaKey
(byte keyHeaderByte, byte[] key) KafkaKey
(MessageType messageType, byte[] key) -
Method Summary
-
Field Details
-
CONTROL_MESSAGE_KAFKA_KEY_LENGTH
public static final int CONTROL_MESSAGE_KAFKA_KEY_LENGTHFor control messages, the Key part of theKafkaKey
includes the producer GUID, segment and sequence number. N.B.: This could be optimized further by defining an Avro record to hold this data, since Avro would use variable length encoding for the two integers, which would be smaller than their regular size. -
HEART_BEAT
-
-
Constructor Details
-
KafkaKey
-
KafkaKey
public KafkaKey(byte keyHeaderByte, @Nonnull byte[] key)
-
-
Method Details
-
getKeyHeaderByte
public byte getKeyHeaderByte()The key header byte is the first byte in the content of the Kafka key. This is significant because it affects Kafka's Log Compaction. ForMessageType.PUT
andMessageType.DELETE
, we want to use the exact same Kafka key, so the header byte needs to be the same. For control messages, however, we want them to be name-spaced on their own, so that they do not collide with the data when Log Compaction runs.- Returns:
- a single byte: '0' for PUT and DELETE, or '2' for CONTROL_MESSAGE
-
isControlMessage
public boolean isControlMessage()- Returns:
- true if this key corresponds to a control message, and false otherwise.
-
getKey
public byte[] getKey()- Returns:
- the content of the key (everything beyond the first byte)
-
getKeyLength
public int getKeyLength() -
toString
-
getHeapSize
public int getHeapSize()- Specified by:
getHeapSize
in interfaceMeasurable
-