K
- The type of the keyV
- The type of the valuepublic class Record<K,V> extends Object
Processor
or a record to forward to downstream processors via ProcessorContext
.
This class encapsulates all the data attributes of a record: the key and value, but
also the timestamp of the record and any record headers.
This class is immutable, though the objects referenced in the attributes of this class
may themselves be mutable.Constructor and Description |
---|
Record(K key,
V value,
long timestamp)
Convenience constructor in case you do not wish to specify any headers.
|
Record(K key,
V value,
long timestamp,
org.apache.kafka.common.header.Headers headers)
The full constructor, specifying all the attributes of the record.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
org.apache.kafka.common.header.Headers |
headers()
The headers of the record.
|
K |
key()
The key of the record.
|
long |
timestamp()
The timestamp of the record.
|
String |
toString() |
V |
value()
The value of the record.
|
Record<K,V> |
withHeaders(org.apache.kafka.common.header.Headers headers)
A convenient way to produce a new record if you only need to change the headers.
|
<NewK> Record<NewK,V> |
withKey(NewK key)
A convenient way to produce a new record if you only need to change the key.
|
Record<K,V> |
withTimestamp(long timestamp)
A convenient way to produce a new record if you only need to change the timestamp.
|
<NewV> Record<K,NewV> |
withValue(NewV value)
A convenient way to produce a new record if you only need to change the value.
|
public Record(K key, V value, long timestamp, org.apache.kafka.common.header.Headers headers)
ProcessorContext.forward(Record)
for
considerations around mutability of keys, values, and headers.key
- The key of the record. May be null.value
- The value of the record. May be null.timestamp
- The timestamp of the record. May not be negative.headers
- The headers of the record. May be null, which will cause subsequent calls
to headers()
to return a non-null, empty, Headers
collection.IllegalArgumentException
- if the timestamp is negative.ProcessorContext.forward(Record)
public Record(K key, V value, long timestamp)
headers()
will return a non-null, empty, Headers
collection.key
- The key of the record. May be null.value
- The value of the record. May be null.timestamp
- The timestamp of the record. May not be negative.IllegalArgumentException
- if the timestamp is negative.public K key()
public V value()
public long timestamp()
public org.apache.kafka.common.header.Headers headers()
public <NewK> Record<NewK,V> withKey(NewK key)
NewK
- The type of the new record's key.key
- The key of the result record. May be null.public <NewV> Record<K,NewV> withValue(NewV value)
NewV
- The type of the new record's value.value
- The value of the result record.public Record<K,V> withTimestamp(long timestamp)
timestamp
- The timestamp of the result record.public Record<K,V> withHeaders(org.apache.kafka.common.header.Headers headers)
ProcessorContext.forward(Record)
for
considerations around mutability of keys, values, and headers.headers
- The headers of the result record.