Record Class KafkaRecordKey

java.lang.Object
java.lang.Record
io.aiven.kafka.connect.amqp.common.KafkaRecordKey
Record Components:
topic - the original topic.
partition - the original partition.
offset - the original offset.
All Implemented Interfaces:
Comparable<KafkaRecordKey>

public record KafkaRecordKey(String topic, int partition, long offset) extends Record implements Comparable<KafkaRecordKey>
A record that is used to track offsets from Kafka. Generally used in maps to track source or sink records.
  • Constructor Summary

    Constructors
    Constructor
    Description
    KafkaRecordKey(String topic, int partition, long offset)
    Creates an instance of a KafkaRecordKey record class.
    KafkaRecordKey(org.apache.kafka.clients.producer.RecordMetadata recordMetadata)
    Creates an instance from a RecordMetadata instance.
    KafkaRecordKey(org.apache.kafka.common.TopicPartition topicPartition, long offset)
    Creates an instance from a TopicPartition object and an offset.
    KafkaRecordKey(org.apache.kafka.connect.sink.SinkRecord sinkRecord)
    Creates an instance from a SinkRecord.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    long
    Returns the value of the offset record component.
    int
    Returns the value of the partition record component.
    Returns the value of the topic record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • KafkaRecordKey

      public KafkaRecordKey(org.apache.kafka.connect.sink.SinkRecord sinkRecord)
      Creates an instance from a SinkRecord.
      Parameters:
      sinkRecord - the sink record to extract data from.
    • KafkaRecordKey

      public KafkaRecordKey(org.apache.kafka.clients.producer.RecordMetadata recordMetadata)
      Creates an instance from a RecordMetadata instance.
      Parameters:
      recordMetadata - the record metadata to extract data from.
    • KafkaRecordKey

      public KafkaRecordKey(org.apache.kafka.common.TopicPartition topicPartition, long offset)
      Creates an instance from a TopicPartition object and an offset.
      Parameters:
      topicPartition - the TopicPartition to use.
      offset - the offset.
    • KafkaRecordKey

      public KafkaRecordKey(String topic, int partition, long offset)
      Creates an instance of a KafkaRecordKey record class.
      Parameters:
      topic - the value for the topic record component
      partition - the value for the partition record component
      offset - the value for the offset record component
  • Method Details

    • compareTo

      public int compareTo(KafkaRecordKey that)
      Specified by:
      compareTo in interface Comparable<KafkaRecordKey>
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • topic

      public String topic()
      Returns the value of the topic record component.
      Returns:
      the value of the topic record component
    • partition

      public int partition()
      Returns the value of the partition record component.
      Returns:
      the value of the partition record component
    • offset

      public long offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component