本文整理匯總了Java中org.apache.kafka.connect.data.Schema.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java Schema.equals方法的具體用法?Java Schema.equals怎麽用?Java Schema.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.kafka.connect.data.Schema
的用法示例。
在下文中一共展示了Schema.equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldChangeSchema
import org.apache.kafka.connect.data.Schema; //導入方法依賴的package包/類
public static boolean shouldChangeSchema(Schema valueSchema, Schema currentSchema, Compatibility compatibility) {
if (currentSchema == null) {
return true;
}
if ((valueSchema.version() == null || currentSchema.version() == null) && compatibility != Compatibility.NONE) {
throw new SchemaProjectorException("Schema version required for " + compatibility.toString() + " compatibility");
}
switch (compatibility) {
case BACKWARD:
case FULL:
return (valueSchema.version()).compareTo(currentSchema.version()) > 0;
case FORWARD:
return (valueSchema.version()).compareTo(currentSchema.version()) < 0;
default:
return !valueSchema.equals(currentSchema);
}
}
示例2: project
import org.apache.kafka.connect.data.Schema; //導入方法依賴的package包/類
public static SinkRecord project(SinkRecord record, Schema currentSchema, Compatibility compatibility) {
switch (compatibility) {
case BACKWARD:
case FULL:
case FORWARD:
Schema sourceSchema = record.valueSchema();
Object value = record.value();
if (sourceSchema == currentSchema || sourceSchema.equals(currentSchema)) {
return record;
}
Object projected = SchemaProjector.project(sourceSchema, value, currentSchema);
return new SinkRecord(record.topic(), record.kafkaPartition(), record.keySchema(),
record.key(), currentSchema, projected, record.kafkaOffset());
default:
return record;
}
}