本文整理匯總了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()));
}
}