Package cz.o2.proxima.direct.io.kafka
Interface ElementSerializer<K,V>
-
- Type Parameters:
K
- type of key read from KafkaV
- type of value read from Kafka
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
KafkaStreamElement.KafkaStreamElementSerializer
,ValueAsBytesSerializer
,ValueAsStringSerializer
public interface ElementSerializer<K,V> extends java.io.Serializable
A parser that transforms KV from Kafka (byte[], byte[]) intoStreamElement
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description org.apache.kafka.common.serialization.Serde<K>
keySerde()
RetrieveSerde
for type K.StreamElement
read(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record, EntityDescriptor entityDesc)
Parse the raw bytes from Kafka and return aStreamElement
.default void
setup(EntityDescriptor entityDescriptor)
Life-cycle method called after being instantiated to be able to parameterize itself from the givenEntityDescriptor
.default boolean
storesSequentialId()
org.apache.kafka.common.serialization.Serde<V>
valueSerde()
RetrieveSerde
for type V.org.apache.kafka.clients.producer.ProducerRecord<K,V>
write(java.lang.String topic, int partition, StreamElement element)
ConvertStreamElement
intoProducerRecord
.
-
-
-
Method Detail
-
setup
default void setup(EntityDescriptor entityDescriptor)
Life-cycle method called after being instantiated to be able to parameterize itself from the givenEntityDescriptor
.- Parameters:
entityDescriptor
- the entity that this serializer will be used for
-
read
@Nullable StreamElement read(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record, EntityDescriptor entityDesc)
Parse the raw bytes from Kafka and return aStreamElement
.- Parameters:
record
- aConsumerRecord
to be parsedentityDesc
- descriptor of entity being read- Returns:
- the
StreamElement
or null on parse error
-
write
org.apache.kafka.clients.producer.ProducerRecord<K,V> write(java.lang.String topic, int partition, StreamElement element)
ConvertStreamElement
intoProducerRecord
.- Parameters:
topic
- the target topicpartition
- the target partitionelement
- theStreamElement
to convert- Returns:
- the
ProducerRecord
to write to Kafka
-
keySerde
org.apache.kafka.common.serialization.Serde<K> keySerde()
RetrieveSerde
for type K.- Returns:
Serde
for key
-
valueSerde
org.apache.kafka.common.serialization.Serde<V> valueSerde()
RetrieveSerde
for type V.- Returns:
Serde
for value
-
storesSequentialId
default boolean storesSequentialId()
- Returns:
true
if this serializer reads and writes sequential IDs ofStreamElement
(if any).
-
-