use of scala.reflect.Manifest in project parquet-mr by apache.
the class ScroogeStructConverter method convertClassToThriftType.
/**
* In composite types, such as the type of the key in a map, since we use reflection to get the type class, this method
* does conversion based on the class provided.
*
* @return converted ThriftType
*/
private ThriftType convertClassToThriftType(String name, Requirement requirement, Manifest<?> typeManifest) {
Class typeClass = typeManifest.runtimeClass();
if (typeManifest.runtimeClass() == boolean.class) {
return new ThriftType.BoolType();
} else if (typeClass == byte.class) {
return new ThriftType.ByteType();
} else if (typeClass == double.class) {
return new ThriftType.DoubleType();
} else if (typeClass == short.class) {
return new ThriftType.I16Type();
} else if (typeClass == int.class) {
return new ThriftType.I32Type();
} else if (typeClass == long.class) {
return new ThriftType.I64Type();
} else if (typeClass == String.class) {
return new ThriftType.StringType();
} else if (typeClass == ByteBuffer.class) {
return new ThriftType.StringType();
} else if (typeClass == scala.collection.Seq.class) {
Manifest<?> a = typeManifest.typeArguments().apply(0);
return convertListTypeField(name, a, requirement);
} else if (typeClass == scala.collection.Set.class) {
Manifest<?> setElementManifest = typeManifest.typeArguments().apply(0);
return convertSetTypeField(name, setElementManifest, requirement);
} else if (typeClass == scala.collection.Map.class) {
List<Manifest<?>> ms = JavaConversions.seqAsJavaList(typeManifest.typeArguments());
Manifest keyManifest = ms.get(0);
Manifest valueManifest = ms.get(1);
return convertMapTypeField(name, keyManifest, valueManifest, requirement);
} else if (com.twitter.scrooge.ThriftEnum.class.isAssignableFrom(typeClass)) {
return convertEnumTypeField(typeClass, name);
} else {
return convertStructFromClass(typeClass);
}
}
Aggregations