Search in sources :

Example 1 with KeyValueEncodingType

use of org.apache.pulsar.common.schema.KeyValueEncodingType in project flink by apache.

the class KeyValueSchemaFactory method createSchema.

@Override
public Schema<KeyValue<K, V>> createSchema(SchemaInfo info) {
    KeyValue<SchemaInfo, SchemaInfo> kvSchemaInfo = decodeKeyValueSchemaInfo(info);
    Schema<K> keySchema = PulsarSchemaUtils.createSchema(kvSchemaInfo.getKey());
    Schema<V> valueSchema = PulsarSchemaUtils.createSchema(kvSchemaInfo.getValue());
    KeyValueEncodingType encodingType = decodeKeyValueEncodingType(info);
    Schema<KeyValue<K, V>> schema = KeyValueSchemaImpl.of(keySchema, valueSchema, encodingType);
    // Append extra class name into schema info properties.
    // KeyValueSchema don't have custom properties builder method, we have to use side effects.
    SchemaInfo schemaInfo = schema.getSchemaInfo();
    Map<String, String> properties = schemaInfo.getProperties();
    properties.put(CLASS_INFO_PLACEHOLDER, KeyValue.class.getName());
    return schema;
}
Also used : KeyValue(org.apache.pulsar.common.schema.KeyValue) KeyValueSchemaInfo.decodeKeyValueEncodingType(org.apache.pulsar.client.impl.schema.KeyValueSchemaInfo.decodeKeyValueEncodingType) KeyValueEncodingType(org.apache.pulsar.common.schema.KeyValueEncodingType) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) KeyValueSchemaInfo.decodeKeyValueSchemaInfo(org.apache.pulsar.client.impl.schema.KeyValueSchemaInfo.decodeKeyValueSchemaInfo)

Aggregations

KeyValueSchemaInfo.decodeKeyValueEncodingType (org.apache.pulsar.client.impl.schema.KeyValueSchemaInfo.decodeKeyValueEncodingType)1 KeyValueSchemaInfo.decodeKeyValueSchemaInfo (org.apache.pulsar.client.impl.schema.KeyValueSchemaInfo.decodeKeyValueSchemaInfo)1 KeyValue (org.apache.pulsar.common.schema.KeyValue)1 KeyValueEncodingType (org.apache.pulsar.common.schema.KeyValueEncodingType)1 SchemaInfo (org.apache.pulsar.common.schema.SchemaInfo)1