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.SerializableA 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()RetrieveSerdefor type K.StreamElementread(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record, EntityDescriptor entityDesc)Parse the raw bytes from Kafka and return aStreamElement.default voidsetup(EntityDescriptor entityDescriptor)Life-cycle method called after being instantiated to be able to parameterize itself from the givenEntityDescriptor.default booleanstoresSequentialId()org.apache.kafka.common.serialization.Serde<V>valueSerde()RetrieveSerdefor type V.org.apache.kafka.clients.producer.ProducerRecord<K,V>write(java.lang.String topic, int partition, StreamElement element)ConvertStreamElementintoProducerRecord.
-
-
-
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- aConsumerRecordto be parsedentityDesc- descriptor of entity being read- Returns:
- the
StreamElementor null on parse error
-
write
org.apache.kafka.clients.producer.ProducerRecord<K,V> write(java.lang.String topic, int partition, StreamElement element)
ConvertStreamElementintoProducerRecord.- Parameters:
topic- the target topicpartition- the target partitionelement- theStreamElementto convert- Returns:
- the
ProducerRecordto write to Kafka
-
keySerde
org.apache.kafka.common.serialization.Serde<K> keySerde()
RetrieveSerdefor type K.- Returns:
Serdefor key
-
valueSerde
org.apache.kafka.common.serialization.Serde<V> valueSerde()
RetrieveSerdefor type V.- Returns:
Serdefor value
-
storesSequentialId
default boolean storesSequentialId()
- Returns:
trueif this serializer reads and writes sequential IDs ofStreamElement(if any).
-
-