static int getCharacterMaxLength(TypeInfo type) { return ((BaseCharTypeInfo)type).getLength(); }
@Override public String getQualifiedName() { return getQualifiedName(typeName, length); }
public static boolean doesPrimitiveMatchTypeParams(HiveBaseChar value, BaseCharTypeInfo typeInfo) { return typeInfo.getLength() == value.getCharacterLength(); } }
public static VarcharTypeInfo getVarcharTypeInfo(int length) { String fullName = BaseCharTypeInfo.getQualifiedName(serdeConstants.VARCHAR_TYPE_NAME, length); return (VarcharTypeInfo) getPrimitiveTypeInfo(fullName); }
public static boolean doesWritableMatchTypeParams(HiveBaseCharWritable writable, BaseCharTypeInfo typeInfo) { return typeInfo.getLength() >= writable.getCharacterLength(); }
public static CharTypeInfo getCharTypeInfo(int length) { String fullName = BaseCharTypeInfo.getQualifiedName(serdeConstants.CHAR_TYPE_NAME, length); return (CharTypeInfo) getPrimitiveTypeInfo(fullName); }
/** * Return the character length of the type * @param typeInfo * @return */ public static int getCharacterLengthForType(PrimitiveTypeInfo typeInfo) { switch (typeInfo.getPrimitiveCategory()) { case STRING: return HiveVarchar.MAX_VARCHAR_LENGTH; case CHAR: case VARCHAR: BaseCharTypeInfo baseCharTypeInfo = (BaseCharTypeInfo) typeInfo; return baseCharTypeInfo.getLength(); default: return 0; } }
@Override public String getQualifiedName() { return getQualifiedName(typeName, length); }
@Override public String getQualifiedName() { return getQualifiedName(typeName, length); }
/** * Helper function to help GenericUDFs determine the return type * character length for char/varchar. * @param poi PrimitiveObjectInspector representing the type * @return character length of the type * @throws UDFArgumentException */ public static int getFixedStringSizeForType(PrimitiveObjectInspector poi) throws UDFArgumentException { // TODO: we can support date, int, .. any types which would have a fixed length value switch (poi.getPrimitiveCategory()) { case CHAR: case VARCHAR: BaseCharTypeInfo typeInfo = (BaseCharTypeInfo) poi.getTypeInfo(); return typeInfo.getLength(); default: throw new UDFArgumentException("No fixed size for type " + poi.getTypeName()); } }
@Override public String getQualifiedName() { return getQualifiedName(typeName, length); }
/** * Helper function to help GenericUDFs determine the return type * character length for char/varchar. * @param poi PrimitiveObjectInspector representing the type * @return character length of the type * @throws UDFArgumentException */ public static int getFixedStringSizeForType(PrimitiveObjectInspector poi) throws UDFArgumentException { // TODO: we can support date, int, .. any types which would have a fixed length value switch (poi.getPrimitiveCategory()) { case CHAR: case VARCHAR: BaseCharTypeInfo typeInfo = (BaseCharTypeInfo) poi.getTypeInfo(); return typeInfo.getLength(); default: throw new UDFArgumentException("No fixed size for type " + poi.getTypeName()); } }
@Override public String getQualifiedName() { return getQualifiedName(typeName, length); }
if (returnTypeInfo instanceof BaseCharTypeInfo) { BaseCharTypeInfo baseCharTypeInfo = (BaseCharTypeInfo) returnTypeInfo; truncStringOutput.setMaxLength(baseCharTypeInfo.getLength());
public static VarcharTypeInfo getVarcharTypeInfo(int length) { String fullName = BaseCharTypeInfo.getQualifiedName(serdeConstants.VARCHAR_TYPE_NAME, length); return (VarcharTypeInfo) getPrimitiveTypeInfo(fullName); }
if (returnType instanceof BaseCharTypeInfo) { BaseCharTypeInfo baseCharTypeInfo = (BaseCharTypeInfo) returnType; truncStringOutput.setMaxLength(baseCharTypeInfo.getLength());
public static CharTypeInfo getCharTypeInfo(int length) { String fullName = BaseCharTypeInfo.getQualifiedName(serdeConstants.CHAR_TYPE_NAME, length); return (CharTypeInfo) getPrimitiveTypeInfo(fullName); }
case VARCHAR: convertedType = dtFactory.createTypeWithCharsetAndCollation( dtFactory.createSqlType(SqlTypeName.VARCHAR, ((BaseCharTypeInfo) type).getLength()), Charset.forName(ConversionUtil.NATIVE_UTF16_CHARSET_NAME), SqlCollation.IMPLICIT); break; case CHAR: convertedType = dtFactory.createTypeWithCharsetAndCollation( dtFactory.createSqlType(SqlTypeName.CHAR, ((BaseCharTypeInfo) type).getLength()), Charset.forName(ConversionUtil.NATIVE_UTF16_CHARSET_NAME), SqlCollation.IMPLICIT); break;
public static VarcharTypeInfo getVarcharTypeInfo(int length) { String fullName = BaseCharTypeInfo.getQualifiedName(serdeConstants.VARCHAR_TYPE_NAME, length); return (VarcharTypeInfo) getPrimitiveTypeInfo(fullName); }