[ 
https://issues.apache.org/jira/browse/KAFKA-3801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15323561#comment-15323561
 ] 

Guozhang Wang commented on KAFKA-3801:
--------------------------------------

Hello [~jeff.klu...@gmail.com] could you present a concrete example that a lot 
of serde instances need to be created on-the-fly? Today for most primitive 
types, users should be able to use {{Serdes.Long}} etc to directly get the 
serde objects.

And also specifically in the description, {{KStream.mapValues}} should not 
require a serde object, right?

> Provide static serialize() and deserialize() for use as method references
> -------------------------------------------------------------------------
>
>                 Key: KAFKA-3801
>                 URL: https://issues.apache.org/jira/browse/KAFKA-3801
>             Project: Kafka
>          Issue Type: Improvement
>          Components: clients, streams
>            Reporter: Jeff Klukas
>            Assignee: Guozhang Wang
>            Priority: Minor
>             Fix For: 0.10.1.0
>
>
> While most calls to {{Serializer.serialize}} and {{Deserializer.deserialize}} 
> are abstracted away in Kafka Streams through the use of `Serdes` classes, 
> there are some instances where developers may want to call them directly. The 
> serializers and deserializers for simple types don't require any 
> configuration and could be static, but currently it's necessary to create an 
> instance to use those methods.
> I'd propose moving serialization logic into a {{static public byte[] 
> serialize(? data)}} method and deserialization logic into a {{static public ? 
> deserialize(byte[] data)}} method. The existing instance methods would simply 
> call the static versions.
> See a full example for LongSerializer and LongDeserializer here:
> https://github.com/apache/kafka/compare/trunk...jklukas:static-serde-methods?expand=1
> In Java 8, these static methods then become available for method references 
> in code like {{kstream.mapValues(LongDeserializer::deserialize)}} without the 
> user needing to create an instance of {{LongDeserializer}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to