K
- key type of serdeV
- value type of serdepublic final class StateSerdes<K,V> extends Object
Constructor and Description |
---|
StateSerdes(String topic,
org.apache.kafka.common.serialization.Serde<K> keySerde,
org.apache.kafka.common.serialization.Serde<V> valueSerde)
Create a context for serialization using the specified serializers and deserializers which
must match the key and value types used as parameters for this object; the state changelog topic
is provided to bind this serde factory to, so that future calls for serialize / deserialize do not
need to provide the topic name any more.
|
Modifier and Type | Method and Description |
---|---|
org.apache.kafka.common.serialization.Deserializer<K> |
keyDeserializer()
Return the key deserializer.
|
K |
keyFrom(byte[] rawKey)
Deserialize the key from raw bytes.
|
org.apache.kafka.common.serialization.Serde<K> |
keySerde()
Return the key serde.
|
org.apache.kafka.common.serialization.Serializer<K> |
keySerializer()
Return the key serializer.
|
byte[] |
rawKey(K key)
Serialize the given key.
|
byte[] |
rawValue(V value)
Serialize the given value.
|
String |
topic()
Return the topic.
|
org.apache.kafka.common.serialization.Deserializer<V> |
valueDeserializer()
Return the value deserializer.
|
V |
valueFrom(byte[] rawValue)
Deserialize the value from raw bytes.
|
org.apache.kafka.common.serialization.Serde<V> |
valueSerde()
Return the value serde.
|
org.apache.kafka.common.serialization.Serializer<V> |
valueSerializer()
Return the value serializer.
|
static <K,V> StateSerdes<K,V> |
withBuiltinTypes(String topic,
Class<K> keyClass,
Class<V> valueClass)
Create a new instance of
StateSerdes for the given state name and key-/value-type classes. |
public StateSerdes(String topic, org.apache.kafka.common.serialization.Serde<K> keySerde, org.apache.kafka.common.serialization.Serde<V> valueSerde)
topic
- the topic namekeySerde
- the serde for keys; cannot be nullvalueSerde
- the serde for values; cannot be nullIllegalArgumentException
- if key or value serde is nullpublic static <K,V> StateSerdes<K,V> withBuiltinTypes(String topic, Class<K> keyClass, Class<V> valueClass)
StateSerdes
for the given state name and key-/value-type classes.K
- the key typeV
- the value typetopic
- the topic namekeyClass
- the class of the key typevalueClass
- the class of the value typeStateSerdes
public org.apache.kafka.common.serialization.Serde<K> keySerde()
public org.apache.kafka.common.serialization.Serde<V> valueSerde()
public org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer()
public org.apache.kafka.common.serialization.Serializer<K> keySerializer()
public org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer()
public org.apache.kafka.common.serialization.Serializer<V> valueSerializer()
public String topic()
public K keyFrom(byte[] rawKey)
rawKey
- the key as raw bytespublic V valueFrom(byte[] rawValue)
rawValue
- the value as raw bytespublic byte[] rawKey(K key)
key
- the key to be serializedpublic byte[] rawValue(V value)
value
- the value to be serialized