Record Class ProduceRecord

java.lang.Object
java.lang.Record
io.krabka.streams.columnar.ProduceRecord
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, or a negative value for none
headers - the ordered Kafka headers

public record ProduceRecord(byte[] key, byte[] value, long timestamp, List<RecordHeader> headers) extends Record
One output record from a columnar sink.

Sinks emit these through BatchCodec.encode(org.apache.arrow.vector.VectorSchemaRoot), and ColumnarRunner.sendAsync(java.util.List, org.apache.kafka.clients.producer.Producer) converts them to Kafka producer records. A timestamp below zero means "no timestamp": the runner then lets the broker or producer assign one. Key and value bytes are defensively copied in both directions.

Example

ProduceRecord output = driver.readOutput("processed-transactions");
assertThat(output.value()).isNotEmpty();
assertThat(output.headers()).contains(new RecordHeader("trace-id", traceId));
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProduceRecord(byte[] key, byte[] value, long timestamp)
    Creates a record without headers.
    ProduceRecord(byte[] key, byte[] value, long timestamp, 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 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

    • ProduceRecord

      public ProduceRecord(byte[] key, byte[] value, long timestamp)
      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, or a negative value for none
    • ProduceRecord

      public ProduceRecord(byte[] key, byte[] value, long timestamp, 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, or a negative value for none
      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
    • headers

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