Source:
TypeDescription convertTypeFromProtobuf(List<OrcProto.Type> types, int rootColumn) { OrcProto.Type type = types.get(rootColumn); switch (type.getKind()) { case BOOLEAN: return TypeDescription.createBoolean(); case BYTE: return TypeDescription.createByte(); case SHORT: return TypeDescription.createShort(); case INT: return TypeDescription.createInt(); case LONG: return TypeDescription.createLong(); case FLOAT: return TypeDescription.createFloat(); case DOUBLE: return TypeDescription.createDouble(); case STRING: return TypeDescription.createString(); case CHAR: return TypeDescription.createChar() .withMaxLength(type.getMaximumLength()); case VARCHAR: return TypeDescription.createVarchar() .withMaxLength(type.getMaximumLength()); case BINARY: return TypeDescription.createBinary(); case TIMESTAMP: return TypeDescription.createTimestamp(); case DATE: return TypeDescription.createDate(); case DECIMAL: { TypeDescription result = TypeDescription.createDecimal(); if (type.hasScale()) { result.withScale(type.getScale()); } if (type.hasPrecision()) { result.withPrecision(type.getPrecision()); } return result; } case LIST: return TypeDescription.createList( convertTypeFromProtobuf(types, type.getSubtypes(0))); case MAP: return TypeDescription.createMap( convertTypeFromProtobuf(types, type.getSubtypes(0)), convertTypeFromProtobuf(types, type.getSubtypes(1))); case STRUCT: { TypeDescription result = TypeDescription.createStruct(); for(int f=0; f < type.getSubtypesCount(); ++f) { result.addField(type.getFieldNames(f), convertTypeFromProtobuf(types, type.getSubtypes(f))); } return result; } case UNION: { TypeDescription result = TypeDescription.createUnion(); for(int f=0; f < type.getSubtypesCount(); ++f) { result.addUnionChild( convertTypeFromProtobuf(types, type.getSubtypes(f))); } return result; } } throw new IllegalArgumentException("Unknown ORC type " + type.getKind()); }

Target:
TypeDescription convertTypeFromProtobuf(List<OrcProto.Type> types, int rootColumn) { OrcProto.Type type = types.get(rootColumn); switch (type.getKind()) { case BOOLEAN: return TypeDescription.createBoolean(); case BYTE: return TypeDescription.createByte(); case SHORT: return TypeDescription.createShort(); case INT: return TypeDescription.createInt(); case LONG: return TypeDescription.createLong(); case FLOAT: return TypeDescription.createFloat(); case DOUBLE: return TypeDescription.createDouble(); case STRING: return TypeDescription.createString(); case CHAR: case VARCHAR: { TypeDescription result = type.getKind() == OrcProto.Type.Kind.CHAR ? TypeDescription.createChar() : TypeDescription.createVarchar(); if (type.hasMaximumLength()) { result.withMaxLength(type.getMaximumLength()); } return result; } case BINARY: return TypeDescription.createBinary(); case TIMESTAMP: return TypeDescription.createTimestamp(); case DATE: return TypeDescription.createDate(); case DECIMAL: { TypeDescription result = TypeDescription.createDecimal(); if (type.hasScale()) { result.withScale(type.getScale()); } if (type.hasPrecision()) { result.withPrecision(type.getPrecision()); } return result; } case LIST: return TypeDescription.createList( convertTypeFromProtobuf(types, type.getSubtypes(0))); case MAP: return TypeDescription.createMap( convertTypeFromProtobuf(types, type.getSubtypes(0)), convertTypeFromProtobuf(types, type.getSubtypes(1))); case STRUCT: { TypeDescription result = TypeDescription.createStruct(); for(int f=0; f < type.getSubtypesCount(); ++f) { result.addField(type.getFieldNames(f), convertTypeFromProtobuf(types, type.getSubtypes(f))); } return result; } case UNION: { TypeDescription result = TypeDescription.createUnion(); for(int f=0; f < type.getSubtypesCount(); ++f) { result.addUnionChild( convertTypeFromProtobuf(types, type.getSubtypes(f))); } return result; } } throw new IllegalArgumentException("Unknown ORC type " + type.getKind()); }