本文整理汇总了Java中org.apache.avro.Schema.getEnumSymbols方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.getEnumSymbols方法的具体用法?Java Schema.getEnumSymbols怎么用?Java Schema.getEnumSymbols使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avro.Schema
的用法示例。
在下文中一共展示了Schema.getEnumSymbols方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkReaderEnumContainsAllWriterEnumSymbols
import org.apache.avro.Schema; //导入方法依赖的package包/类
private SchemaCompatibilityResult checkReaderEnumContainsAllWriterEnumSymbols(
final Schema reader, final Schema writer, final Stack<String> location) {
SchemaCompatibilityResult result = SchemaCompatibilityResult.compatible();
location.push("symbols");
final Set<String> symbols = new TreeSet<String>(writer.getEnumSymbols());
symbols.removeAll(reader.getEnumSymbols());
if (!symbols.isEmpty()) {
result = SchemaCompatibilityResult.incompatible(
SchemaIncompatibilityType.MISSING_ENUM_SYMBOLS, reader, writer,
symbols.toString(), location);
}
// POP "symbols" literal
location.pop();
return result;
}
示例2: detectConverter
import org.apache.avro.Schema; //导入方法依赖的package包/类
static private AbstractAvroValueConverter detectConverter(Schema schema) {
Schema.Type avroType = schema.getType();
switch (avroType) {
case NULL:
return new AvroNullConverter(schema);
case BOOLEAN:
return new AvroBooleanConverter(schema);
case STRING:
return new AvroStringConverter(schema);
case INT:
return new AvroIntConverter(schema);
case LONG:
return new AvroLongConverter(schema);
case FLOAT:
return new AvroFloatConverter(schema);
case DOUBLE:
return new AvroDoubleConverter(schema);
case ENUM:
return new AvroEnumConverter(schema, schema.getEnumSymbols());
case FIXED:
return new AvroFixedConverter(schema);
case UNION:
for (Schema s : schema.getTypes()) {
if (s.getType() != Schema.Type.NULL)
return detectConverter(s);
}
return new AvroNullConverter(schema);
case ARRAY:
return new AvroArrayConverter(schema, detectConverter(schema.getElementType()));
case MAP:
return new AvroMapConverter(schema, detectConverter(schema.getValueType()));
case RECORD:
ImmutableMap.Builder<String, AbstractAvroValueConverter> builder = ImmutableMap.builder();
for (Schema.Field f : schema.getFields()) {
builder.put(f.name(), detectConverter(f.schema()));
}
return new AvroRecordConverter(schema, builder.build());
default:
throw new RuntimeException(String.format("%s of %s is unsupported avro type", schema.getType(), schema.getName()));
}
}