@Test public void testKafkaAvroSerializerWithProjection() { byte[] bytes; Object obj; IndexedRecord avroRecord = createExtendedSpecificAvroRecord(); bytes = avroSerializer.serialize(topic, avroRecord); obj = avroDecoder.fromBytes(bytes); GenericData.Record extendedUser = (GenericData.Record) obj; assertTrue( "Returned object should be a GenericData Record", GenericData.Record.class.isInstance(obj) ); assertNotNull(extendedUser.get("age")); obj = avroDecoder.fromBytes(bytes, User.getClassSchema()); assertTrue( "Returned object should be a GenericData Record", GenericData.Record.class.isInstance(obj) ); GenericData.Record decoderProjection = (GenericData.Record) obj; assertEquals("testUser", decoderProjection.get("name").toString()); assertNull(decoderProjection.get("age")); obj = avroDeserializer.deserialize(topic, bytes, User.getClassSchema()); assertTrue( "Returned object should be a GenericData Record", GenericData.Record.class.isInstance(obj) ); GenericData.Record deserializeProjection = (GenericData.Record) obj; assertEquals("testUser", deserializeProjection.get("name").toString()); assertNull(deserializeProjection.get("age")); }
@Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] serialize(String topic, Object record); @Override void close(); }
KafkaAvroSerializer extends AbstractKafkaAvroSerializer implements Serializer<Object> { @Override public byte[] serialize(String topic, Object record) { if (record == null) { return null; } AvroSchema schema = new AvroSchema(AvroSchemaUtils.getSchema(record, useSchemaReflection)); return serializeImpl(getSubjectName(topic, isKey, record, schema), record, schema); } KafkaAvroSerializer();  KafkaAvroSerializer(SchemaRegistryClient client);  KafkaAvroSerializer(SchemaRegistryClient client, Map<String, ?> props); @Override void configure(Map<String, ?> configs, boolean isKey); @Override byte[] serialize(String topic, Object record); @Override void close();  }