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


Java Field類代碼示例

本文整理匯總了Java中com.twitter.elephantbird.thrift.TStructDescriptor.Field的典型用法代碼示例。如果您正苦於以下問題:Java Field類的具體用法?Java Field怎麽用?Java Field使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Field類屬於com.twitter.elephantbird.thrift.TStructDescriptor包,在下文中一共展示了Field類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toStructType

import com.twitter.elephantbird.thrift.TStructDescriptor.Field; //導入依賴的package包/類
private static StructType toStructType(TStructDescriptor struct) {
  List<Field> fields = struct.getFields();
  List<ThriftField> children = new ArrayList<ThriftField>(fields.size());
  for (Field field : fields) {
    Requirement req =
        field.getFieldMetaData() == null ?
            Requirement.OPTIONAL :
            Requirement.fromType(field.getFieldMetaData().requirementType);
    children.add(toThriftField(field.getName(), field, req));
  }
  return new StructType(children, structOrUnionType(struct.getThriftClass()));
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:13,代碼來源:ThriftSchemaConverter.java

示例2: toThriftField

import com.twitter.elephantbird.thrift.TStructDescriptor.Field; //導入依賴的package包/類
private static ThriftField toThriftField(String name, Field field, ThriftField.Requirement requirement) {
  ThriftType type;
  switch (ThriftTypeID.fromByte(field.getType())) {
    case STOP:
    case VOID:
    default:
      throw new UnsupportedOperationException("can't convert type of " + field);
    case BOOL:
      type = new BoolType();
      break;
    case BYTE:
      type = new ByteType();
      break;
    case DOUBLE:
      type = new DoubleType();
      break;
    case I16:
      type = new I16Type();
      break;
    case I32:
      type = new I32Type();
      break;
    case I64:
      type = new I64Type();
      break;
    case STRING:
      StringType stringType = new StringType();
      FieldMetaData fieldMetaData = field.getFieldMetaData();
      // There is no real binary type (see THRIFT-1920) in Thrift,
      // binary data is represented by String type with an additional binary flag.
      if (fieldMetaData != null && fieldMetaData.valueMetaData.isBinary()) {
        stringType.setBinary(true);
      }
      type = stringType;
      break;
    case STRUCT:
      type = toStructType(field.gettStructDescriptor());
      break;
    case MAP:
      final Field mapKeyField = field.getMapKeyField();
      final Field mapValueField = field.getMapValueField();
      type = new ThriftType.MapType(
          toThriftField(mapKeyField.getName(), mapKeyField, requirement),
          toThriftField(mapValueField.getName(), mapValueField, requirement));
      break;
    case SET:
      final Field setElemField = field.getSetElemField();
      type = new ThriftType.SetType(toThriftField(setElemField.getName(), setElemField, requirement));
      break;
    case LIST:
      final Field listElemField = field.getListElemField();
      type = new ThriftType.ListType(toThriftField(listElemField.getName(), listElemField, requirement));
      break;
    case ENUM:
      Collection<TEnum> enumValues = field.getEnumValues();
      List<EnumValue> values = new ArrayList<ThriftType.EnumValue>();
      for (TEnum tEnum : enumValues) {
        values.add(new EnumValue(tEnum.getValue(), tEnum.toString()));
      }
      type = new EnumType(values);
      break;
  }
  return new ThriftField(name, field.getId(), requirement, type);
}
 
開發者ID:apache,項目名稱:parquet-mr,代碼行數:65,代碼來源:ThriftSchemaConverter.java


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