Class ValueAsBytesSerializer
- java.lang.Object
-
- cz.o2.proxima.direct.io.kafka.serializer.ValueAsBytesSerializer
-
- All Implemented Interfaces:
ElementSerializer<byte[],byte[]>,java.io.Serializable
public class ValueAsBytesSerializer extends java.lang.Object implements ElementSerializer<byte[],byte[]>
AElementSerializerthat reads values from kafka (discards keys) and returns values as byte arrays.You must subclass this class to create zero-parameter constructor.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedValueAsBytesSerializer(UnaryFunction<EntityDescriptor,AttributeDescriptor<byte[]>> readAttributeFn)protectedValueAsBytesSerializer(java.lang.String attrName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.kafka.common.serialization.Serde<byte[]>keySerde()RetrieveSerdefor type K.StreamElementread(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord, EntityDescriptor entityDescriptor)Parse the raw bytes from Kafka and return aStreamElement.voidsetup(EntityDescriptor entityDescriptor)Life-cycle method called after being instantiated to be able to parameterize itself from the givenEntityDescriptor.org.apache.kafka.common.serialization.Serde<byte[]>valueSerde()RetrieveSerdefor type V.org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]>write(java.lang.String topic, int partition, StreamElement streamElement)ConvertStreamElementintoProducerRecord.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.direct.io.kafka.ElementSerializer
storesSequentialId
-
-
-
-
Constructor Detail
-
ValueAsBytesSerializer
protected ValueAsBytesSerializer(java.lang.String attrName)
-
ValueAsBytesSerializer
protected ValueAsBytesSerializer(UnaryFunction<EntityDescriptor,AttributeDescriptor<byte[]>> readAttributeFn)
-
-
Method Detail
-
setup
public void setup(EntityDescriptor entityDescriptor)
Description copied from interface:ElementSerializerLife-cycle method called after being instantiated to be able to parameterize itself from the givenEntityDescriptor.- Specified by:
setupin interfaceElementSerializer<byte[],byte[]>- Parameters:
entityDescriptor- the entity that this serializer will be used for
-
read
@Nullable public StreamElement read(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> consumerRecord, EntityDescriptor entityDescriptor)
Description copied from interface:ElementSerializerParse the raw bytes from Kafka and return aStreamElement.- Specified by:
readin interfaceElementSerializer<byte[],byte[]>- Parameters:
consumerRecord- aConsumerRecordto be parsedentityDescriptor- descriptor of entity being read- Returns:
- the
StreamElementor null on parse error
-
write
public org.apache.kafka.clients.producer.ProducerRecord<byte[],byte[]> write(java.lang.String topic, int partition, StreamElement streamElement)Description copied from interface:ElementSerializerConvertStreamElementintoProducerRecord.- Specified by:
writein interfaceElementSerializer<byte[],byte[]>- Parameters:
topic- the target topicpartition- the target partitionstreamElement- theStreamElementto convert- Returns:
- the
ProducerRecordto write to Kafka
-
keySerde
public org.apache.kafka.common.serialization.Serde<byte[]> keySerde()
Description copied from interface:ElementSerializerRetrieveSerdefor type K.- Specified by:
keySerdein interfaceElementSerializer<byte[],byte[]>- Returns:
Serdefor key
-
valueSerde
public org.apache.kafka.common.serialization.Serde<byte[]> valueSerde()
Description copied from interface:ElementSerializerRetrieveSerdefor type V.- Specified by:
valueSerdein interfaceElementSerializer<byte[],byte[]>- Returns:
Serdefor value
-
-