本文整理汇总了Java中org.apache.hive.hcatalog.data.schema.HCatFieldSchema.getTypeInfo方法的典型用法代码示例。如果您正苦于以下问题:Java HCatFieldSchema.getTypeInfo方法的具体用法?Java HCatFieldSchema.getTypeInfo怎么用?Java HCatFieldSchema.getTypeInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hive.hcatalog.data.schema.HCatFieldSchema
的用法示例。
在下文中一共展示了HCatFieldSchema.getTypeInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGeneralSchemaFromHCatFieldSchema
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入方法依赖的package包/类
public static IField getGeneralSchemaFromHCatFieldSchema( final HCatFieldSchema hCatFieldSchema ) throws IOException{
if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.ARRAY ){
HCatSchema arrayElementSchema = hCatFieldSchema.getArrayElementSchema();
return new ArrayContainerField( hCatFieldSchema.getName() , getGeneralSchemaFromHCatFieldSchema( arrayElementSchema.get(0) ) );
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.MAP ){
HCatSchema mapValueElementSchema = hCatFieldSchema.getMapValueSchema();
return new MapContainerField( hCatFieldSchema.getName() , getGeneralSchemaFromHCatFieldSchema( mapValueElementSchema.get(0) ) );
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.STRUCT ){
HCatSchema structSchema = hCatFieldSchema.getStructSubSchema();
StructContainerField field = new StructContainerField( hCatFieldSchema.getName() );
for( int i = 0 ; i < structSchema.size() ; i++ ){
field.set( getGeneralSchemaFromHCatFieldSchema( structSchema.get(i) ) );
}
return field;
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.PRIMITIVE ){
TypeInfo typeInfo = hCatFieldSchema.getTypeInfo();
return HiveSchemaFactory.getGeneralSchema( hCatFieldSchema.getName() , typeInfo );
}
else{
throw new IOException( "Unknown HCatalog field type : " + hCatFieldSchema.toString() );
}
}
示例2: convertClobType
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入方法依赖的package包/类
private Object convertClobType(Object val, HCatFieldSchema hfs) {
HCatFieldSchema.Type hfsType = hfs.getType();
ClobRef cr = (ClobRef) val;
String s = cr.isExternal() ? cr.toString() : cr.getData();
if (hfsType == HCatFieldSchema.Type.STRING) {
return s;
} else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
HiveVarchar hvc = new HiveVarchar(s, vti.getLength());
return hvc;
} else if (hfsType == HCatFieldSchema.Type.CHAR) {
CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
HiveChar hc = new HiveChar(s, cti.getLength());
return hc;
}
return null;
}
示例3: convertStringTypes
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入方法依赖的package包/类
private Object convertStringTypes(Object val, HCatFieldSchema hfs) {
HCatFieldSchema.Type hfsType = hfs.getType();
if (hfsType == HCatFieldSchema.Type.STRING
|| hfsType == HCatFieldSchema.Type.VARCHAR
|| hfsType == HCatFieldSchema.Type.CHAR) {
String str = val.toString();
if (doHiveDelimsReplacement) {
str = FieldFormatter.hiveStringReplaceDelims(str,
hiveDelimsReplacement, hiveDelimiters);
}
if (hfsType == HCatFieldSchema.Type.STRING) {
return str;
} else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
HiveVarchar hvc = new HiveVarchar(str, vti.getLength());
return hvc;
} else if (hfsType == HCatFieldSchema.Type.CHAR) {
CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
HiveChar hc = new HiveChar(val.toString(), cti.getLength());
return hc;
}
} else if (hfsType == HCatFieldSchema.Type.DECIMAL) {
BigDecimal bd = new BigDecimal(val.toString(), MathContext.DECIMAL128);
HiveDecimal hd = HiveDecimal.create(bd);
return hd;
}
return null;
}
示例4: convertBooleanTypes
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入方法依赖的package包/类
private Object convertBooleanTypes(Object val, HCatFieldSchema hfs) {
HCatFieldSchema.Type hfsType = hfs.getType();
Boolean b = (Boolean) val;
if (hfsType == HCatFieldSchema.Type.BOOLEAN) {
return b;
} else if (hfsType == HCatFieldSchema.Type.TINYINT) {
return (byte) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.SMALLINT) {
return (short) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.INT) {
return (int) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.BIGINT) {
return (long) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.FLOAT) {
return (float) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.DOUBLE) {
return (double) (b ? 1 : 0);
} else if (hfsType == HCatFieldSchema.Type.STRING) {
return val.toString();
} else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength());
return hvc;
} else if (hfsType == HCatFieldSchema.Type.CHAR) {
CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
HiveChar hChar = new HiveChar(val.toString(), cti.getLength());
return hChar;
}
return null;
}
示例5: get
import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入方法依赖的package包/类
public static IHCatalogPrimitiveConverter get( final HCatFieldSchema hCatFieldSchema ) throws IOException{
if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.ARRAY ){
return new HCatalogNestPrimitiveConverter();
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.MAP ){
return new HCatalogNestPrimitiveConverter();
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.STRUCT ){
return new HCatalogNestPrimitiveConverter();
}
else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.PRIMITIVE ){
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo)hCatFieldSchema.getTypeInfo();
if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.BINARY ){
return new HCatalogBytesPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.BOOLEAN ){
return new HCatalogBooleanPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.BYTE ){
return new HCatalogBytePrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.DOUBLE ){
return new HCatalogDoublePrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.FLOAT ){
return new HCatalogFloatPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.INT ){
return new HCatalogIntegerPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.LONG ){
return new HCatalogLongPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.SHORT ){
return new HCatalogShortPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.STRING ){
return new HCatalogStringPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.DATE ){
return new HCatalogDefaultPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.TIMESTAMP ){
return new HCatalogDefaultPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.VOID ){
return new HCatalogDefaultPrimitiveConverter();
}
else if( primitiveTypeInfo.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.UNKNOWN ){
return new HCatalogDefaultPrimitiveConverter();
}
else {
return new HCatalogDefaultPrimitiveConverter();
}
}
else{
throw new IOException( "Unknown HCatalog field type : " + hCatFieldSchema.toString() );
}
}