Package org.apache.kafka.streams.state
Class StateSerdes<K,V>
java.lang.Object
org.apache.kafka.streams.state.StateSerdes<K,V>
- Type Parameters:
K
- key type of serdeV
- value type of serde
Factory for creating serializers / deserializers for state stores in Kafka Streams.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate 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. -
Method Summary
Modifier and TypeMethodDescriptionReturn the key deserializer.keyFrom
(byte[] rawKey) Deserialize the key from raw bytes.keySerde()
Return the key serde.Return the key serializer.byte[]
Serialize the given key.byte[]
Serialize the given value.topic()
Return the topic.Return the value deserializer.valueFrom
(byte[] rawValue) Deserialize the value from raw bytes.Return the value serde.Return the value serializer.static <K,
V> StateSerdes<K, V> withBuiltinTypes
(String topic, Class<K> keyClass, Class<V> valueClass) Create a new instance ofStateSerdes
for the given state name and key-/value-type classes.
-
Field Details
-
TIMESTAMP_SIZE
public static final int TIMESTAMP_SIZE- See Also:
-
BOOLEAN_SIZE
public static final int BOOLEAN_SIZE- See Also:
-
-
Constructor Details
-
StateSerdes
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.- Parameters:
topic
- the topic namekeySerde
- the serde for keys; cannot be nullvalueSerde
- the serde for values; cannot be null- Throws:
IllegalArgumentException
- if key or value serde is null
-
-
Method Details
-
withBuiltinTypes
public static <K,V> StateSerdes<K,V> withBuiltinTypes(String topic, Class<K> keyClass, Class<V> valueClass) Create a new instance ofStateSerdes
for the given state name and key-/value-type classes.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
topic
- the topic namekeyClass
- the class of the key typevalueClass
- the class of the value type- Returns:
- a new instance of
StateSerdes
-
keySerde
Return the key serde.- Returns:
- the key serde
-
valueSerde
Return the value serde.- Returns:
- the value serde
-
keyDeserializer
Return the key deserializer.- Returns:
- the key deserializer
-
keySerializer
Return the key serializer.- Returns:
- the key serializer
-
valueDeserializer
Return the value deserializer.- Returns:
- the value deserializer
-
valueSerializer
Return the value serializer.- Returns:
- the value serializer
-
topic
Return the topic.- Returns:
- the topic
-
keyFrom
Deserialize the key from raw bytes.- Parameters:
rawKey
- the key as raw bytes- Returns:
- the key as typed object
-
valueFrom
Deserialize the value from raw bytes.- Parameters:
rawValue
- the value as raw bytes- Returns:
- the value as typed object
-
rawKey
Serialize the given key.- Parameters:
key
- the key to be serialized- Returns:
- the serialized key
-
rawValue
Serialize the given value.- Parameters:
value
- the value to be serialized- Returns:
- the serialized value
-