K
- key type of serdeV
- value type of serdepublic final class StateSerdes<K,V> extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BOOLEAN_SIZE |
static int |
TIMESTAMP_SIZE |
Constructor and Description |
---|
StateSerdes(String topic,
Serde<K> keySerde,
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 |
---|---|
Deserializer<K> |
keyDeserializer()
Return the key deserializer.
|
K |
keyFrom(byte[] rawKey)
Deserialize the key from raw bytes.
|
Serde<K> |
keySerde()
Return the key serde.
|
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.
|
Deserializer<V> |
valueDeserializer()
Return the value deserializer.
|
V |
valueFrom(byte[] rawValue)
Deserialize the value from raw bytes.
|
Serde<V> |
valueSerde()
Return the value serde.
|
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 static final int TIMESTAMP_SIZE
public static final int BOOLEAN_SIZE
public StateSerdes(String topic, Serde<K> keySerde, 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 Deserializer<K> keyDeserializer()
public Serializer<K> keySerializer()
public Deserializer<V> valueDeserializer()
public 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