Status
Current state: Under Discussion
Discussion thread: NA
PR: https://github.com/apache/kafka/pull/12545
Motivation
Reduce Fetcher#parseRecord() memory copy: we can direct use ByteBuffer instead of byte[] to deserialize
Public Interfaces
We propose adding default method Deserializer#deserialize(String, Headers, ByteBuffer).
Class | deserialize(String, Headers, ByteBuffer) |
---|---|
Deserializer | default T deserialize(String topic, Headers headers, ByteBuffer data) { |
ByteBufferDeserializer | @Override |
StringDeserializer | @Override |
Proposed Changes
Deserializer
add default methoddeserialize(String, Headers, ByteBuffer)
;- Invoke
Deserializer#deserialize(String, Headers, ByteBuffer)
instead ofDeserializer#deserialize(String, Headers, byte[])
inFetcher#parseRecord(TopicPartition, RecordBatch, Record)
.
Compatibility, Deprecation, and Migration Plan
This proposal has no compatibility issues, we just add default method deserialize(String, Headers, ByteBuffer) which is compatible with the existing Deserializers.
Rejected Alternatives
Another solution I thought of is PoolArea, just like netty, but this solution is more complicated.