public ThriftField toThriftField()

in scalding-parquet-scrooge/src/main/java/com/twitter/scalding/parquet/scrooge/ScroogeStructConverter.java [165:221]


  public ThriftField toThriftField(ThriftStructFieldInfo scroogeField) {
    Requirement requirement = getRequirementType(scroogeField);
    String fieldName = scroogeField.tfield().name;
    short fieldId = scroogeField.tfield().id;
    byte thriftTypeByte = scroogeField.tfield().type;
    ThriftTypeID typeId = ThriftTypeID.fromByte(thriftTypeByte);
    ThriftType thriftType;
    switch (typeId) {
      case BOOL:
        thriftType = new ThriftType.BoolType();
        break;
      case BYTE:
        thriftType = new ThriftType.ByteType();
        break;
      case DOUBLE:
        thriftType = new ThriftType.DoubleType();
        break;
      case I16:
        thriftType = new ThriftType.I16Type();
        break;
      case I32:
        thriftType = new ThriftType.I32Type();
        break;
      case I64:
        thriftType = new ThriftType.I64Type();
        break;
      case STRING:
        ThriftType.StringType stringType = new ThriftType.StringType();
        // There is no real binary type (see THRIFT-1920) in Thrift,
        // binary data is represented by String type with an additional binary flag.
        if (!String.class.equals(scroogeField.manifest().runtimeClass())) {
          stringType.setBinary(true);
        }
        thriftType = stringType;
        break;
      case STRUCT:
        thriftType = convertStructTypeField(scroogeField);
        break;
      case MAP:
        thriftType = convertMapTypeField(scroogeField, requirement);
        break;
      case SET:
        thriftType = convertSetTypeField(scroogeField, requirement);
        break;
      case LIST:
        thriftType = convertListTypeField(scroogeField, requirement);
        break;
      case ENUM:
        thriftType = convertEnumTypeField(scroogeField);
        break;
      case STOP:
      case VOID:
      default:
        throw new IllegalArgumentException("can't convert type " + typeId);
    }
    return new ThriftField(fieldName, fieldId, requirement, thriftType);
  }