K
- key type of serdeV
- value type of serdepublic final class StateSerdes<K,V>
extends java.lang.Object
Constructor and Description |
---|
StateSerdes(java.lang.String stateName,
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.
|
java.lang.String |
stateName()
Return the name of the state.
|
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(java.lang.String stateName,
java.lang.Class<K> keyClass,
java.lang.Class<V> valueClass)
Create a new instance of
StateSerdes for the given state name and key-/value-type classes. |
public StateSerdes(java.lang.String stateName, org.apache.kafka.common.serialization.Serde<K> keySerde, org.apache.kafka.common.serialization.Serde<V> valueSerde)
stateName
- the name of the statekeySerde
- the serde for keys; cannot be nullvalueSerde
- the serde for values; cannot be nulljava.lang.IllegalArgumentException
- if key or value serde is nullpublic static <K,V> StateSerdes<K,V> withBuiltinTypes(java.lang.String stateName, java.lang.Class<K> keyClass, java.lang.Class<V> valueClass)
StateSerdes
for the given state name and key-/value-type classes.K
- the key typeV
- the value typestateName
- the name of the statekeyClass
- 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 java.lang.String stateName()
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