public int getMaxLength() { CharTypeInfo ti = (CharTypeInfo) typeInfo; return ti.getLength(); } }
public int getMaxLength() { return ((CharTypeInfo)typeInfo).getLength(); } }
@Override public String getDisplayString(String[] children) { assert (children.length == 1); StringBuilder sb = new StringBuilder(); sb.append("CAST( "); sb.append(children[0]); sb.append(" AS CHAR("); sb.append("" + typeInfo.getLength()); sb.append(")"); sb.append(")"); return sb.toString(); }
@Override public String getDisplayString(String[] children) { assert (children.length == 1); StringBuilder sb = new StringBuilder(); sb.append("CAST( "); sb.append(children[0]); sb.append(" AS CHAR("); sb.append("" + typeInfo.getLength()); sb.append(")"); return sb.toString(); }
@Override public void transientInit() throws HiveException { super.transientInit(); maxLength = ((CharTypeInfo) inputTypeInfos[0]).getLength(); }
public LazyHiveChar(LazyHiveCharObjectInspector oi) { super(oi); maxLength = ((CharTypeInfo)oi.getTypeInfo()).getLength(); data = new HiveCharWritable(); }
LazyBinaryHiveChar(WritableHiveCharObjectInspector oi) { super(oi); maxLength = ((CharTypeInfo)oi.getTypeInfo()).getLength(); data = new HiveCharWritable(); }
private static int getVarcharLength(TypeInfo hiveType) { int length = -1; if (hiveType instanceof PrimitiveTypeInfo) { PrimitiveTypeInfo hivePrimitiveType = (PrimitiveTypeInfo) hiveType; switch (hivePrimitiveType.getPrimitiveCategory()) { case CHAR: length = ((CharTypeInfo) hivePrimitiveType).getLength(); break; case VARCHAR: length = ((VarcharTypeInfo) hivePrimitiveType).getLength(); break; default: break; } } return length; } }
private Field allocatePrimitiveField(TypeInfo sourceTypeInfo, DataTypePhysicalVariation dataTypePhysicalVariation) { final PrimitiveTypeInfo sourcePrimitiveTypeInfo = (PrimitiveTypeInfo) sourceTypeInfo; final PrimitiveCategory sourcePrimitiveCategory = sourcePrimitiveTypeInfo.getPrimitiveCategory(); final int maxLength; switch (sourcePrimitiveCategory) { case CHAR: maxLength = ((CharTypeInfo) sourcePrimitiveTypeInfo).getLength(); break; case VARCHAR: maxLength = ((VarcharTypeInfo) sourcePrimitiveTypeInfo).getLength(); break; default: // No additional data type specific setting. maxLength = 0; break; } return new Field(sourcePrimitiveCategory, dataTypePhysicalVariation, maxLength); }
@Override public HiveChar getPrimitiveJavaObject(Object o) { // check input object's length, if it doesn't match // then output a new primitive with the correct params. if (o == null) { return null; } if ((o instanceof Text) || (o instanceof TimestampWritableV2) || (o instanceof HiveDecimalWritable) || (o instanceof DoubleWritable) || (o instanceof FloatWritable) || (o instanceof LongWritable) || (o instanceof IntWritable) || (o instanceof BooleanWritable)) { String str = o.toString(); return new HiveChar(str, ((CharTypeInfo)typeInfo).getLength()); } HiveCharWritable writable = ((HiveCharWritable) o); if (doesWritableMatchTypeParams(writable)) { return writable.getHiveChar(); } return getPrimitiveWithParams(writable); }
private void initTargetEntry(int logicalColumnIndex, int projectionColumnNum, TypeInfo typeInfo) { isConvert[logicalColumnIndex] = false; projectionColumnNums[logicalColumnIndex] = projectionColumnNum; targetTypeInfos[logicalColumnIndex] = typeInfo; if (typeInfo.getCategory() == Category.PRIMITIVE) { final PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; final PrimitiveCategory primitiveCategory = primitiveTypeInfo.getPrimitiveCategory(); switch (primitiveCategory) { case CHAR: maxLengths[logicalColumnIndex] = ((CharTypeInfo) primitiveTypeInfo).getLength(); break; case VARCHAR: maxLengths[logicalColumnIndex] = ((VarcharTypeInfo) primitiveTypeInfo).getLength(); break; default: // No additional data type specific setting. break; } } }
@Override public HiveChar getPrimitiveJavaObject(Object o) { if (o == null) { return null; } HiveChar ret = ((LazyHiveChar) o).getWritableObject().getHiveChar(); if (!BaseCharUtils.doesPrimitiveMatchTypeParams( ret, (CharTypeInfo)typeInfo)) { HiveChar newValue = new HiveChar(ret, ((CharTypeInfo)typeInfo).getLength()); return newValue; } return ret; }
@Override public HiveCharWritable getPrimitiveWritableObject(Object o) { // check input object's length, if it doesn't match // then output new writable with correct params. if (o == null) { return null; } if ((o instanceof Text) || (o instanceof TimestampWritableV2) || (o instanceof HiveDecimalWritable) || (o instanceof DoubleWritable) || (o instanceof FloatWritable) || (o instanceof LongWritable) || (o instanceof IntWritable) || (o instanceof BooleanWritable)) { String str = o.toString(); HiveCharWritable hcw = new HiveCharWritable(); hcw.set(str, ((CharTypeInfo)typeInfo).getLength()); return hcw; } HiveCharWritable writable = ((HiveCharWritable) o); if (doesWritableMatchTypeParams((HiveCharWritable) o)) { return writable; } return getWritableWithParams(writable); }
public static HiveChar getRandHiveChar(Random r, CharTypeInfo charTypeInfo, boolean isUnicodeOk) { final int maxLength = 1 + r.nextInt(charTypeInfo.getLength()); final String randomString = getRandString(r, 100, isUnicodeOk); return new HiveChar(randomString, maxLength); }
public Object copyObject(Object o) { if (o == null) { return null; } if (o instanceof Text) { String str = ((Text)o).toString(); HiveCharWritable hcw = new HiveCharWritable(); hcw.set(str, ((CharTypeInfo)typeInfo).getLength()); return hcw; } HiveCharWritable writable = (HiveCharWritable) o; if (doesWritableMatchTypeParams((HiveCharWritable) o)) { return new HiveCharWritable(writable); } return getWritableWithParams(writable); }
private void initTargetEntry(int logicalColumnIndex, int projectionColumnNum, TypeInfo typeInfo) { isConvert[logicalColumnIndex] = false; projectionColumnNums[logicalColumnIndex] = projectionColumnNum; Category category = typeInfo.getCategory(); targetCategories[logicalColumnIndex] = category; if (category == Category.PRIMITIVE) { PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; PrimitiveCategory primitiveCategory = primitiveTypeInfo.getPrimitiveCategory(); targetPrimitiveCategories[logicalColumnIndex] = primitiveCategory; switch (primitiveCategory) { case CHAR: maxLengths[logicalColumnIndex] = ((CharTypeInfo) primitiveTypeInfo).getLength(); break; case VARCHAR: maxLengths[logicalColumnIndex] = ((VarcharTypeInfo) primitiveTypeInfo).getLength(); break; default: // No additional data type specific setting. break; } } }
return createVarcharType(((VarcharTypeInfo) typeInfo).getLength()); case CHAR: return createCharType(((CharTypeInfo) typeInfo).getLength()); case DATE: return DATE;
public static TypeQualifiers fromTypeInfo(PrimitiveTypeInfo pti) { TypeQualifiers result = null; if (pti instanceof VarcharTypeInfo) { result = new TypeQualifiers(); result.setCharacterMaximumLength(((VarcharTypeInfo)pti).getLength()); } else if (pti instanceof CharTypeInfo) { result = new TypeQualifiers(); result.setCharacterMaximumLength(((CharTypeInfo)pti).getLength()); } else if (pti instanceof DecimalTypeInfo) { result = new TypeQualifiers(); result.setPrecision(((DecimalTypeInfo)pti).precision()); result.setScale(((DecimalTypeInfo)pti).scale()); } return result; }
private void addTopLevelConversion(int logicalColumnIndex, TypeInfo targetTypeInfo) { final Field field = topLevelFields[logicalColumnIndex]; field.setIsConvert(true); if (field.getIsPrimitive()) { PrimitiveTypeInfo targetPrimitiveTypeInfo = (PrimitiveTypeInfo) targetTypeInfo; switch (targetPrimitiveTypeInfo.getPrimitiveCategory()) { case CHAR: field.setMaxLength(((CharTypeInfo) targetPrimitiveTypeInfo).getLength()); break; case VARCHAR: field.setMaxLength(((VarcharTypeInfo) targetPrimitiveTypeInfo).getLength()); break; default: // No additional data type specific setting. break; } field.setConversionWritable( VectorizedBatchUtil.getPrimitiveWritable(field.getPrimitiveCategory())); } }