Package org.apache.hadoop.hive.serde2.typeinfo

Examples of org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams


    switch (typeCategory) {
      case VARCHAR:
        int maxLength = getCommonLength(
            TypeInfoUtils.getCharacterLengthForType(a),
            TypeInfoUtils.getCharacterLengthForType(b));
        VarcharTypeParams varcharParams = new VarcharTypeParams();
        varcharParams.setLength(maxLength);
        // Generate type name so that we can retrieve the TypeInfo for that type.
        String typeName = PrimitiveObjectInspectorUtils
            .getTypeEntryFromTypeSpecs(typeCategory, varcharParams).toString();
        return TypeInfoFactory.getPrimitiveTypeInfo(typeName);
View Full Code Here


    switch (token) {
    case HiveParser.TOK_VARCHAR:
      PrimitiveCategory primitiveCategory = PrimitiveCategory.VARCHAR;
      typeName = TokenToTypeName.get(token);
      VarcharTypeParams varcharParams = ParseUtils.getVarcharParams(typeName, node);
      typeName = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(
          primitiveCategory, varcharParams).toString();
      break;
    default:
      typeName = TokenToTypeName.get(token);
View Full Code Here

            return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
          case STRING:
            return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
          case VARCHAR:
            // For varchar we need to retrieve the string length from the TypeInfo.
            VarcharTypeParams varcharParams = (VarcharTypeParams)
                ParameterizedPrimitiveTypeUtils.getTypeParamsFromTypeInfo(info);
            if (varcharParams == null) {
              throw new IllegalArgumentException("varchar type used without type params");
            }
            return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
View Full Code Here

      case VARCHAR:
        if (!type.hasMaximumLength()) {
          throw new UnsupportedOperationException(
              "Illegal use of varchar type without length in ORC type definition.");
        }
        VarcharTypeParams varcharParams = new VarcharTypeParams();
        varcharParams.setLength(type.getMaximumLength());
        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
            PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(
                PrimitiveCategory.VARCHAR, varcharParams));
      case TIMESTAMP:
        return PrimitiveObjectInspectorFactory.javaTimestampObjectInspector;
View Full Code Here

    ObjectInspector outputOI = null;
    switch (inputType) {
      case VARCHAR:
        // return type should have same length as the input.
        returnType = inputType;
        VarcharTypeParams varcharParams = new VarcharTypeParams();
        varcharParams.setLength(
            GenericUDFUtils.StringHelper.getFixedStringSizeForType(argumentOI));
        outputOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
            argumentOI);
        break;
      default:
View Full Code Here

    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 VARCHAR:
          VarcharTypeParams varcharParams = null;
          varcharParams = (VarcharTypeParams) poi.getTypeParams();
          if (varcharParams == null || varcharParams.length < 0) {
            throw new UDFArgumentException("varchar type used without type params");
          }
          return varcharParams.length;
View Full Code Here

    ObjectInspector outputOI = null;
    switch (inputType) {
      case VARCHAR:
        // return type should have same length as the input.
        returnType = inputType;
        VarcharTypeParams varcharParams = new VarcharTypeParams();
        varcharParams.setLength(
            GenericUDFUtils.StringHelper.getFixedStringSizeForType(argumentOI));
        outputOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
            argumentOI);
        break;
      default:
View Full Code Here

            type.setKind(OrcProto.Type.Kind.STRING);
            break;
          case VARCHAR:
            // The varchar length needs to be written to file and should be available
            // from the object inspector
            VarcharTypeParams varcharParams = (VarcharTypeParams)
                ParameterizedPrimitiveTypeUtils.getTypeParamsFromPrimitiveObjectInspector(
                    (PrimitiveObjectInspector) treeWriter.inspector);
            if (varcharParams == null) {
              throw new IllegalArgumentException("No varchar length specified in ORC type");
            }
            type.setKind(Type.Kind.VARCHAR);
            type.setMaximumLength(varcharParams.getLength());
            break;
          case BINARY:
            type.setKind(OrcProto.Type.Kind.BINARY);
            break;
          case TIMESTAMP:
View Full Code Here

      returnHelper = new GenericUDFUtils.StringHelper(returnType);
      switch (returnType) {
        case STRING:
          return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
        case VARCHAR:
          VarcharTypeParams varcharParams = new VarcharTypeParams();
          varcharParams.setLength(returnLength);
          return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
              PrimitiveObjectInspectorUtils.getTypeEntryFromTypeSpecs(returnType, varcharParams));
        default:
          throw new UDFArgumentException("Unexpected CONCAT return type of " + returnType);
      }
View Full Code Here

    if (node.getChildCount() != 1) {
      throw new SemanticException("Bad params for type " + typeName);
    }

    try {
      VarcharTypeParams typeParams = new VarcharTypeParams();
      String lengthStr = node.getChild(0).getText();
      Integer length = Integer.valueOf(lengthStr);
      typeParams.setLength(length.intValue());
      typeParams.validateParams();
      return typeParams;
    } catch (SerDeException err) {
      throw new SemanticException(err);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.