本文整理汇总了C#中TypeInfo.getCategory方法的典型用法代码示例。如果您正苦于以下问题:C# TypeInfo.getCategory方法的具体用法?C# TypeInfo.getCategory怎么用?C# TypeInfo.getCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeInfo
的用法示例。
在下文中一共展示了TypeInfo.getCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createObjectInspector
public static ObjectInspector createObjectInspector(TypeInfo info)
{
switch (info.getCategory())
{
case ObjectInspectorCategory.PRIMITIVE:
switch (((PrimitiveTypeInfo)info).getPrimitiveCategory())
{
case PrimitiveCategory.FLOAT:
return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
case PrimitiveCategory.DOUBLE:
return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
case PrimitiveCategory.BOOLEAN:
return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
case PrimitiveCategory.BYTE:
return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
case PrimitiveCategory.SHORT:
return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
case PrimitiveCategory.INT:
return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
case PrimitiveCategory.LONG:
return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
case PrimitiveCategory.BINARY:
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
case PrimitiveCategory.STRING:
return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
case PrimitiveCategory.CHAR:
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
(PrimitiveTypeInfo)info);
case PrimitiveCategory.VARCHAR:
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
(PrimitiveTypeInfo)info);
case PrimitiveCategory.TIMESTAMP:
return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
case PrimitiveCategory.DATE:
return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
case PrimitiveCategory.DECIMAL:
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
(PrimitiveTypeInfo)info);
default:
throw new ArgumentException("Unknown primitive type " +
((PrimitiveTypeInfo)info).getPrimitiveCategory());
}
case ObjectInspectorCategory.STRUCT:
return new OrcStructInspector((StructTypeInfo)info);
case ObjectInspectorCategory.UNION:
return new OrcUnion.OrcUnionObjectInspector((UnionTypeInfo)info);
case ObjectInspectorCategory.MAP:
return new OrcMapObjectInspector((MapTypeInfo)info);
case ObjectInspectorCategory.LIST:
return new OrcListObjectInspector((ListTypeInfo)info);
default:
throw new ArgumentException("Unknown type " +
info.getCategory());
}
}
示例2: convertTypeInfo
public static TypeDescription convertTypeInfo(TypeInfo info)
{
switch (info.getCategory())
{
case ObjectInspectorCategory.PRIMITIVE:
{
PrimitiveTypeInfo pinfo = (PrimitiveTypeInfo)info;
switch (pinfo.getPrimitiveCategory())
{
case PrimitiveCategory.BOOLEAN:
return TypeDescription.createBoolean();
case PrimitiveCategory.BYTE:
return TypeDescription.createByte();
case PrimitiveCategory.SHORT:
return TypeDescription.createShort();
case PrimitiveCategory.INT:
return TypeDescription.createInt();
case PrimitiveCategory.LONG:
return TypeDescription.createLong();
case PrimitiveCategory.FLOAT:
return TypeDescription.createFloat();
case PrimitiveCategory.DOUBLE:
return TypeDescription.createDouble();
case PrimitiveCategory.STRING:
return TypeDescription.createString();
case PrimitiveCategory.DATE:
return TypeDescription.createDate();
case PrimitiveCategory.TIMESTAMP:
return TypeDescription.createTimestamp();
case PrimitiveCategory.BINARY:
return TypeDescription.createBinary();
case PrimitiveCategory.DECIMAL:
{
DecimalTypeInfo dinfo = (DecimalTypeInfo)pinfo;
return TypeDescription.createDecimal()
.withScale(dinfo.scale())
.withPrecision(dinfo.precision());
}
case PrimitiveCategory.VARCHAR:
{
BaseCharTypeInfo cinfo = (BaseCharTypeInfo)pinfo;
return TypeDescription.createVarchar()
.withMaxLength(cinfo.getLength());
}
case PrimitiveCategory.CHAR:
{
BaseCharTypeInfo cinfo = (BaseCharTypeInfo)pinfo;
return TypeDescription.createChar()
.withMaxLength(cinfo.getLength());
}
default:
throw new ArgumentException("ORC doesn't handle primitive" +
" category " + pinfo.getPrimitiveCategory());
}
}
case ObjectInspectorCategory.LIST:
{
ListTypeInfo linfo = (ListTypeInfo)info;
return TypeDescription.createList
(convertTypeInfo(linfo.getListElementTypeInfo()));
}
case ObjectInspectorCategory.MAP:
{
MapTypeInfo minfo = (MapTypeInfo)info;
return TypeDescription.createMap
(convertTypeInfo(minfo.getMapKeyTypeInfo()),
convertTypeInfo(minfo.getMapValueTypeInfo()));
}
case ObjectInspectorCategory.UNION:
{
UnionTypeInfo minfo = (UnionTypeInfo)info;
TypeDescription result = TypeDescription.createUnion();
foreach (TypeInfo child in minfo.getAllUnionObjectTypeInfos())
{
result.addUnionChild(convertTypeInfo(child));
}
return result;
}
case ObjectInspectorCategory.STRUCT:
{
StructTypeInfo sinfo = (StructTypeInfo)info;
TypeDescription result = TypeDescription.createStruct();
foreach (string fieldName in sinfo.getAllStructFieldNames())
{
result.addField(fieldName,
convertTypeInfo(sinfo.getStructFieldTypeInfo(fieldName)));
}
return result;
}
default:
throw new ArgumentException("ORC doesn't handle " +
info.getCategory());
}
}