-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add KeyValueSchema to satisfy org.apache.kafka.connect.connector.ConnectRecord #2885
Conversation
/** | ||
* Key Value Schema whose underneath schemas are AvroSchema. | ||
*/ | ||
static Schema<?> KeyValue(Class key, Class value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually I think it might be better to do following:
- be able to construct keyvalue schema with
SchemaType
- make the default as JSON, since we are using JSON as default schema for other places.
static <K, V> Schema<KeyValue<K, V>> KeyValue(Class<K> key, Class<V> value, SchemaType type) {
checkArgument(SchemaType.JSON == type || SchemaType.AVRO == type);
...
}
static <K, V> Schema<KeyValue<K, V>> KeyValue(Class<K> key, Class<V> value) {
return KeyValue(key, value, SchemaType.JSON);
...
}
return new KeyValueSchema<>(AvroSchema.of(key), AvroSchema.of(value)); | ||
} | ||
|
||
static Schema<?> KeyValue(Schema key, Schema value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static <K, V> Schema<KeyValue<K, V>> KeyValue(Schema<K> key, Schema<V> value);
@Slf4j | ||
public class KeyValueSchema<K, V> implements Schema<KeyValue<K, V>> { | ||
@Getter | ||
private Schema<K> keySchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final?
@Getter | ||
private Schema<K> keySchema; | ||
@Getter | ||
private Schema<V> valueSchema; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finall?
return value; | ||
} | ||
|
||
public void setKey(K key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to setKey or setValue? If not, I would start with making key and value immutable.
rerun java8 tests |
|
||
// schemaInfo combined by KeySchemaInfo and ValueSchemaInfo: | ||
// [keyInfo.length][keyInfo][valueInfo.length][ValueInfo] | ||
private SchemaInfo schemaInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final?
run integration tests |
Kafka org.apache.kafka.connect.connector.ConnectRecord has both key and value schema.
Currently we need a KeyValueSchema to achieve it and support debezium.
There will be another PR to do the convert between KeyValueSchema and org.apache.kafka.connect.data.Schema.