Record Class ConsumedRecord

java.lang.Object
java.lang.Record
io.krabka.streams.columnar.ConsumedRecord
Record Components:
key - the record key bytes, or null for a keyless record
value - the record value bytes
timestamp - the record timestamp in epoch milliseconds
partition - the source partition number
offset - the record offset within the partition
headers - the ordered Kafka headers

public record ConsumedRecord(byte[] key, byte[] value, long timestamp, int partition, long offset, List<RecordHeader> headers) extends Record
One input record in a partition batch.

This is the broker-independent form of a fetched Kafka record: the runner and the test driver both build it, and BatchCodec.decode(java.util.List) turns a list of them into one Arrow batch. Key and value bytes are defensively copied in both directions, so a record can be shared freely between tests and threads.

Example

var record = new ConsumedRecord(key, arrowIpcBytes, 1_700_000_000_000L, 0, 42L);
try (var batch = codec.decode("transactions", List.of(record))) {
    // process the batch
}
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConsumedRecord(byte[] key, byte[] value, long timestamp, int partition, long offset)
    Creates a record without headers.
    ConsumedRecord(byte[] key, byte[] value, long timestamp, int partition, long offset, List<RecordHeader> headers)
    Copies the mutable components so the record is immutable.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the headers record component.
    byte[]
    key()
    Returns a copy of the record key.
    long
    Returns the value of the offset record component.
    int
    Returns the value of the partition record component.
    long
    Returns the value of the timestamp record component.
    final String
    Returns a string representation of this record class.
    byte[]
    Returns a copy of the record value.

    Methods inherited from class Object

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

    • ConsumedRecord

      public ConsumedRecord(byte[] key, byte[] value, long timestamp, int partition, long offset)
      Creates a record without headers.
      Parameters:
      key - the record key bytes, or null for a keyless record
      value - the record value bytes
      timestamp - the record timestamp in epoch milliseconds
      partition - the source partition number
      offset - the record offset within the partition
    • ConsumedRecord

      public ConsumedRecord(byte[] key, byte[] value, long timestamp, int partition, long offset, List<RecordHeader> headers)
      Copies the mutable components so the record is immutable.
      Parameters:
      key - the record key bytes, or null for a keyless record
      value - the record value bytes
      timestamp - the record timestamp in epoch milliseconds
      partition - the source partition number
      offset - the record offset within the partition
      headers - the ordered Kafka headers
  • Method Details

    • key

      public byte[] key()
      Returns a copy of the record key.
      Returns:
      a fresh copy of the key bytes, or null for a keyless record
    • value

      public byte[] value()
      Returns a copy of the record value.
      Returns:
      a fresh copy of the value bytes
    • toString

      public final 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 the compare method from their corresponding wrapper classes.
      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.
    • timestamp

      public long timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp 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
    • headers

      public List<RecordHeader> headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component