5 Aralık 2023 Salı

Compact Serialization Custom Configuration

Örnek
Şu satırı dahil ederiz
import com.hazelcast.nio.serialization.compact.CompactSerializer;
import com.hazelcast.nio.serialization.compact.CompactReader;
import com.hazelcast.nio.serialization.compact.CompactWriter;
Örnek - Member Side Custom Configuration
Şöyle yaparız
public class Employee {
   ...
}

public class EmployeeSerializer implements CompactSerializer<Employee> {
  @Override
  public Employee read(CompactReader reader) {
    long id = reader.readInt64("id");
    String name = reader.readString("name");
    return new Employee(id, name);
  }

  @Override
  public void write(CompactWriter writer, Employee employee) {
    writer.writeInt64("id", employee.getId());
    writer.writeString("name", employee.getName());
  }

  @Override
  public Class<Employee> getCompactClass() {
    return Employee.class;
  }

  @Override
  public String getTypeName() {
    return "employee";
  }
}

Config config = new Config();
config.getSerializationConfig()
        .getCompactSerializationConfig()
        .addSerializer(new EmployeeSerializer());
Örnek - Client Side Custom Configuration
İstemci tarafından IMap.put işlemi için call stack şöyle . Yazılan byte[] nesnesi HeapData nesnesine çevrili.
write:16, MyWorkerSerializer (com.colak.serilization.compact.serializerconfiguration)
write:7, MyWorkerSerializer (com.colak.serilization.compact.serializerconfiguration)
buildSchema:396, CompactStreamSerializer (com.hazelcast.internal.serialization.impl.compact)
writeObject:147, CompactStreamSerializer (com.hazelcast.internal.serialization.impl.compact)
write:116, CompactStreamSerializer (com.hazelcast.internal.serialization.impl.compact)
write:109, CompactStreamSerializer (com.hazelcast.internal.serialization.impl.compact)
write:39, StreamSerializerAdapter (com.hazelcast.internal.serialization.impl)
toBytes:238, AbstractSerializationService (com.hazelcast.internal.serialization.impl)
toBytes:217, AbstractSerializationService (com.hazelcast.internal.serialization.impl)
toData:202, AbstractSerializationService (com.hazelcast.internal.serialization.impl)
toData:157, AbstractSerializationService (com.hazelcast.internal.serialization.impl)
toData:76, ClientProxy (com.hazelcast.client.impl.spi)
putInternal:553, ClientMapProxy (com.hazelcast.client.impl.proxy)
put:275, ClientMapProxy (com.hazelcast.client.impl.proxy)

Hiç yorum yok:

Yorum Gönder

THIRD-PARTY.txt Dosyası

Kullanılan harici kütüphanelerin sürümleri bu dosyada Dosyanın yolu şöyle hazelcast/licenses/THIRD-PARTY.txt