當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.NULL屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:17,代碼來源:SchemaUtil.java

示例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);
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:24,代碼來源:AccumuloStore.java

示例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;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:10,代碼來源:SchemaUtil.java

示例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;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:11,代碼來源:AccumuloStore.java

示例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;
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:11,代碼來源:AccumuloStore.java

示例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();
	}
 
開發者ID:Comcast,項目名稱:pipeclamp,代碼行數:10,代碼來源:AvroUtil.java

示例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;
	}
 
開發者ID:Comcast,項目名稱:pipeclamp,代碼行數:9,代碼來源:AvroUtil.java

示例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
	}
 
開發者ID:Comcast,項目名稱:pipeclamp,代碼行數:8,代碼來源:AvroUtil.java


注:本文中的org.apache.avro.Schema.Type.NULL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。