Search in sources :

Example 1 with DelimitedFormat

use of io.confluent.ksql.serde.delimited.DelimitedFormat in project ksql by confluentinc.

the class ProducerFactory method getProducer.

static DataGenProducer getProducer(final Format keyFormat, final Format valueFormat, final String valueDelimiter, final Properties props) {
    final KsqlConfig ksqlConfig = new KsqlConfig(props);
    final Optional<SchemaRegistryClient> srClient = SchemaRegistryClientFactory.getSrClient(keyFormat, valueFormat, ksqlConfig);
    final SerializerFactory<GenericKey> keySerializerFactory = keySerializerFactory(keyFormat, ksqlConfig, srClient);
    final Map<String, String> formatInfoProperties = new HashMap<>();
    if (valueDelimiter != null) {
        if (!(valueFormat instanceof DelimitedFormat)) {
            throw new IllegalArgumentException("valueDelimiter can only be specified with delimited format");
        }
        formatInfoProperties.put(DelimitedFormat.DELIMITER, valueDelimiter);
    }
    final SerializerFactory<GenericRow> valueSerializerFactory = valueSerializerFactory(valueFormat, ksqlConfig, srClient, formatInfoProperties);
    return new DataGenProducer(keySerializerFactory, valueSerializerFactory);
}
Also used : HashMap(java.util.HashMap) DelimitedFormat(io.confluent.ksql.serde.delimited.DelimitedFormat) KsqlConfig(io.confluent.ksql.util.KsqlConfig) GenericRow(io.confluent.ksql.GenericRow) GenericKey(io.confluent.ksql.GenericKey) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)

Aggregations

SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 GenericKey (io.confluent.ksql.GenericKey)1 GenericRow (io.confluent.ksql.GenericRow)1 DelimitedFormat (io.confluent.ksql.serde.delimited.DelimitedFormat)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 HashMap (java.util.HashMap)1