Interface SerializerFactory<K>

Type Parameters:
K - the key type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SerializerFactory<K>
Factory interface for creating key serializers. This allows clients to provide custom serializers (e.g., Protocol Buffer serializers) without needing to extend or modify the core fast client implementation.

The factory is called during client initialization when the key schema is available. Implementations should be thread-safe as they may be called from multiple threads.

Example usage for Protocol Buffers:


 SerializerFactory<MyKeyProto> protoKeyFactory = 
     (keySchema) -> new ProtoToAvroRecordSerializer<>(keySchema);

 ClientConfig config = new ClientConfig.ClientConfigBuilder()
     .setKeySerializerFactory(protoKeyFactory)
     .build();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    createSerializer(org.apache.avro.Schema keySchema)
    Create a serializer for the given key schema.
  • Method Details

    • createSerializer

      RecordSerializer<K> createSerializer(org.apache.avro.Schema keySchema)
      Create a serializer for the given key schema.
      Parameters:
      keySchema - the Avro schema for keys (keys are always Avro format in Venice storage)
      Returns:
      a record serializer that can serialize keys to Avro bytes; must not return null
      Throws:
      IllegalArgumentException - if the schema is not compatible with the serializer