Skip to content

Commit

Permalink
Fix AvroSchema cast
Browse files Browse the repository at this point in the history
  • Loading branch information
GraciMndzSNG committed Oct 27, 2023
1 parent fd6b1e3 commit ed43cef
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,22 @@
import com.sngular.kloadgen.extractor.extractors.Extractor;
import com.sngular.kloadgen.extractor.extractors.ExtractorRegistry;
import com.sngular.kloadgen.model.FieldValueMapping;

//import com.sngular.kloadgen.model.json.Schema;
import io.confluent.kafka.schemaregistry.avro.AvroSchema;
import org.apache.avro.Schema;
public class AvroExtractor implements ExtractorRegistry<Object> {

static Map<SchemaRegistryEnum, Extractor> schemaRegistryMap = Map.of(CONFLUENT, new AvroConfluentExtractor(), APICURIO,
new AvroApicurioExtractor());

public final List<FieldValueMapping> processSchema(final Object schema, SchemaRegistryEnum registryEnum) {
return schemaRegistryMap.get(registryEnum).processSchema(schema);
Schema rawschema;
if(schema instanceof AvroSchema) {
rawschema = ((AvroSchema)schema).rawSchema();
}else {
rawschema = (Schema) schema;
}
return schemaRegistryMap.get(registryEnum).processSchema(rawschema);
}

public final List<String> getSchemaNameList(final String schema, SchemaRegistryEnum registryEnum) {
Expand Down

0 comments on commit ed43cef

Please sign in to comment.