Werner Daehn created KAFKA-4853:
-----------------------------------
Summary: ByteBufferSerializer does a memcopy
Key: KAFKA-4853
URL: https://issues.apache.org/jira/browse/KAFKA-4853
Project: Kafka
Issue Type: Bug
Components: clients
Affects Versions: 0.10.1.1
Environment: all
Reporter: Werner Daehn
Priority: Minor
When using the ByteBufferSerializer and its backing byte[] has either an offset
or is not of the exact length, then a memcopy takes place.
You do have a byte[] already but wrapped inside a ByteBuffer and yet the entire
(large) payload is copied to a byte[]?
The reason why this is done is obvious, the entire serialization framework
works on the datatype byte[]. And since this datatype does not have an offset
and a length information, the copy is necessary.
But actually, I would argue into the reverse direction. The root problem is
that the serialization is using the byte[].
Change the serialize() method to return a ByteBuffer instead.
The ByteArraySerializer would wrap the byte[] into a ByteBuffer with offset=0
and length=data.length.
All other serializers the same.
But for those cases where the ByteBufferSerializer is used, you have the extra
options and methods.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)