本文整理汇总了Java中org.apache.avro.Schema.getFullName方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.getFullName方法的具体用法?Java Schema.getFullName怎么用?Java Schema.getFullName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avro.Schema
的用法示例。
在下文中一共展示了Schema.getFullName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalValidate
import org.apache.avro.Schema; //导入方法依赖的package包/类
private void internalValidate(Schema schema) throws SchemaValidationException {
if (schema.getType() == RECORD) {
String name = schema.getFullName();
if (recordTypeNames.contains(name)) {
return;
}
recordTypeNames.add(name);
for (Field field : schema.getFields()) {
internalValidate(field.schema());
}
} else if (schema.getType() == MAP) {
internalValidate(schema.getValueType());
} else if (schema.getType() == ARRAY) {
internalValidate(schema.getElementType());
} else if (schema.getType() == UNION) {
boolean containsBytes = false;
boolean containsString = false;
for (Schema unionSchema : schema.getTypes()) {
if (unionSchema.getType() == Schema.Type.BYTES) {
containsBytes = true;
} else if (unionSchema.getType() == Schema.Type.STRING) {
containsString = true;
}
if (containsBytes && containsString) {
String message = "Schema contains a variant of union[bytes, string]: " + unionSchema.toString();
throw new SchemaValidationException(message);
}
if (COMPOSITE_TYPES.contains(unionSchema)) {
internalValidate(unionSchema);
}
}
}
}
示例2: schemaNameEquals
import org.apache.avro.Schema; //导入方法依赖的package包/类
/**
* Tests the equality of two Avro named schemas.
*
* <p> Matching includes reader name aliases. </p>
*
* @param reader Named reader schema.
* @param writer Named writer schema.
* @return whether the names of the named schemas match or not.
*/
public static boolean schemaNameEquals(final Schema reader, final Schema writer) {
final String writerFullName = writer.getFullName();
if (objectsEqual(reader.getFullName(), writerFullName)) {
return true;
}
// Apply reader aliases:
if (reader.getAliases().contains(writerFullName)) {
return true;
}
return false;
}