本文整理匯總了Java中org.apache.avro.Schema.Type.NULL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Type.NULL屬性的具體用法?Java Type.NULL怎麽用?Java Type.NULL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.avro.Schema.Type
的用法示例。
在下文中一共展示了Type.NULL屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSinglePrimitiveTypeOfUnion
public static PrimitiveType getSinglePrimitiveTypeOfUnion(Schema fieldSchema) {
PrimitiveType primitiveType = null;
List<Schema> unionTypes = fieldSchema.getTypes();
for (Schema unionType : unionTypes) {
if (unionType.getType() != Type.NULL) {
if (PrimitiveType.isPrimitive(unionType)) {
if (primitiveType == null) {
primitiveType = PrimitiveType.getPrimitiveType(unionType);
} else {
primitiveType = null;
break;
}
}
}
}
return primitiveType;
}
示例2: fromBytes
public Object fromBytes(Schema schema, byte data[]) throws GoraException {
Schema fromSchema = null;
if (schema.getType() == Type.UNION) {
try {
Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
int unionIndex = decoder.readIndex();
List<Schema> possibleTypes = schema.getTypes();
fromSchema = possibleTypes.get(unionIndex);
Schema effectiveSchema = possibleTypes.get(unionIndex);
if (effectiveSchema.getType() == Type.NULL) {
decoder.readNull();
return null;
} else {
data = decoder.readBytes(null).array();
}
} catch (IOException e) {
LOG.error(e.getMessage());
throw new GoraException("Error decoding union type: ", e);
}
} else {
fromSchema = schema;
}
return fromBytes(encoder, fromSchema, data);
}
示例3: isMultiChoiceUnion
public static boolean isMultiChoiceUnion(Schema unionSchema) {
List<Schema> unionTypes = unionSchema.getTypes();
int nbrOfNoNullChild = 0;
for (Schema unionType : unionTypes) {
if (unionType.getType() != Type.NULL) {
nbrOfNoNullChild++;
}
}
return nbrOfNoNullChild > 1;
}
示例4: firstNullSchemaTypeIndex
private int firstNullSchemaTypeIndex(Schema toSchema) {
List<Schema> possibleTypes = toSchema.getTypes();
int unionIndex = 0;
for (int i = 0; i < possibleTypes.size(); i++ ) {
Type pType = possibleTypes.get(i).getType();
if (pType == Type.NULL) { // FIXME HUGE kludge to pass tests
unionIndex = i; break;
}
}
return unionIndex;
}
示例5: firstNotNullSchemaTypeIndex
private int firstNotNullSchemaTypeIndex(Schema toSchema) {
List<Schema> possibleTypes = toSchema.getTypes();
int unionIndex = 0;
for (int i = 0; i < possibleTypes.size(); i++ ) {
Type pType = possibleTypes.get(i).getType();
if (pType != Type.NULL) { // FIXME HUGE kludge to pass tests
unionIndex = i; break;
}
}
return unionIndex;
}
示例6: primaryTypeIn
public static Type primaryTypeIn(Schema schema) {
if (schema.getType() == Type.UNION) {
for (Schema sch : schema.getTypes()) {
if (sch.getType() == Type.NULL) continue;
return sch.getType(); // TODO what about more complex UNIONs ?
}
}
return schema.getType();
}
示例7: allowsNull
public static boolean allowsNull(Schema schema) {
if (schema.getType() == Type.UNION) {
for (Schema sch : schema.getTypes()) {
if (sch.getType() == Type.NULL) return true;
}
};
return false;
}
示例8: nonNullSchemaIn
public static Schema nonNullSchemaIn(List<Schema> types) {
for (Schema sch : types) {
if (sch.getType() == Type.NULL) continue;
return sch;
}
return null; // won't get here
}