Interface DeserializerFactory<V>

Type Parameters:
V - the value 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 DeserializerFactory<V>
Factory interface for creating value deserializers. This allows clients to provide custom deserializers (e.g., Protocol Buffer deserializers) without needing to extend or modify the core fast client implementation.

The factory is called when a new value schema is encountered. The deserializer will be cached and reused for subsequent reads with the same schema pair.

Implementations should be thread-safe as they may be called from multiple threads.

Example usage for Protocol Buffers:


 DeserializerFactory<MyValueProto> protoValueFactory = 
     (writerSchema, readerSchema) -> new RecordDeserializerToProto<>(writerSchema, MyValueProto.class);

 ClientConfig config = new ClientConfig.ClientConfigBuilder()
     .setValueDeserializerFactory(protoValueFactory)
     .build();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    createDeserializer(org.apache.avro.Schema writerSchema, org.apache.avro.Schema readerSchema)
    Create a deserializer for the given writer and reader schemas.
  • Method Details

    • createDeserializer

      RecordDeserializer<V> createDeserializer(org.apache.avro.Schema writerSchema, org.apache.avro.Schema readerSchema)
      Create a deserializer for the given writer and reader schemas.

      Venice supports schema evolution, so the writer schema (used when data was written) may differ from the reader schema (used when reading). The deserializer should handle this schema evolution appropriately.

      Parameters:
      writerSchema - the schema that was used when the value was written
      readerSchema - the schema to use when reading the value (may be same as writer schema)
      Returns:
      a record deserializer that can deserialize Avro bytes to the value type; must not return null
      Throws:
      IllegalArgumentException - if the schemas are not compatible