Closed masesdevelopers closed 4 months ago
It is possible to add a property, named UseKafkaClassForSupportedTypes
with default value set to false
, to decide which kind of serializer use:
false
: the serializer will be the .NET one, e.g. int
will be converted with BitConverter.GetBytes
into byte array
and BitConverter.ToInt32
from byte array
to int
:
IntegerSerializer
and BitConverter.GetBytes
:Apache Kafka | CLR (source from GitHub) |
---|---|
```java
public class IntegerSerializer implements Serializer |
```c#
public static byte[] GetBytes(int value)
{
byte[] bytes = new byte[sizeof(int)];
Unsafe.As |
true
: the current serializer will be used, e.g. int
will be converted with IntegerSerializer.Serialize
into byte array
and IntegerDeserializer.Deserialize
from byte array
to int
:
Meanwhile on the property UseHeaders
will be added the public setter to give to users of subclasses of SerDes, e.g. JSonSerDes, to remove the constraint imposed by the code in case of needs.
The local serializers stub invokes remote serializers: each time there is a conversion the JVM is impacted like in https://github.com/masesgroup/KNet/blob/721fe074212d4e221630853368beaab6a11bf120/src/net/KNet/Specific/Serialization/KNetSerialization.cs#L240 or https://github.com/masesgroup/KNet/blob/721fe074212d4e221630853368beaab6a11bf120/src/net/KNet/Specific/Serialization/KNetSerialization.cs#L347
Each conversion moves data between CLR and JVM:
bool
,int
,double
, etc) is sent to JVMbyte array
byte array
is returned to the caller that insert it within e.g. aProducerRecord
ProducerRecord
send back again the array to the JVMThe same happens in opposite with
ConsumerRecord
:ConsumerRecord
byte array
is requested to the JVM which send it back to the CLRbyte array
back again to the JVMbool
,int
,double
, etc)Originally posted by @masesdevelopers in https://github.com/masesgroup/KNet/issues/53#issuecomment-1984765101