Examples of ConstantObjectInspector


Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    if (colType.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {

      // constant string projection Ex: select "hello" from table
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantStringObjectInspector) {

        // some UDFs return writable constant strings (fixed width)
        // Ex: select upper("hello") from table
        WritableConstantStringObjectInspector wcsoi = (WritableConstantStringObjectInspector) oi;

        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableStringObjectInspector) {

        // some UDFs may emit strings of variable length. like pattern matching
        // UDFs. it's hard to find the length of such UDFs.
        // return the variable length from config
        return configVarLen;
      }
    } else if (colType.startsWith(serdeConstants.VARCHAR_TYPE_NAME)) {

      // constant varchar projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveVarcharObjectInspector) {

        WritableConstantHiveVarcharObjectInspector wcsoi =
            (WritableConstantHiveVarcharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveVarcharObjectInspector) {
        return ((WritableHiveVarcharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.startsWith(serdeConstants.CHAR_TYPE_NAME)) {

      // constant char projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveCharObjectInspector) {

        WritableConstantHiveCharObjectInspector wcsoi =
            (WritableConstantHiveCharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveCharObjectInspector) {
        return ((WritableHiveCharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME)) {

      // constant byte arrays
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        BytesWritable bw = ((BytesWritable) coi.getWritableConstantValue());
        return bw.getLength();
      } else if (oi instanceof WritableConstantBinaryObjectInspector) {

        // writable constant byte arrays
        WritableConstantBinaryObjectInspector wcboi = (WritableConstantBinaryObjectInspector) oi;
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    if (colType.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {

      // constant string projection Ex: select "hello" from table
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantStringObjectInspector) {

        // some UDFs return writable constant strings (fixed width)
        // Ex: select upper("hello") from table
        WritableConstantStringObjectInspector wcsoi = (WritableConstantStringObjectInspector) oi;

        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableStringObjectInspector) {

        // some UDFs may emit strings of variable length. like pattern matching
        // UDFs. it's hard to find the length of such UDFs.
        // return the variable length from config
        return configVarLen;
      }
    } else if (colType.startsWith(serdeConstants.VARCHAR_TYPE_NAME)) {

      // constant varchar projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveVarcharObjectInspector) {

        WritableConstantHiveVarcharObjectInspector wcsoi =
            (WritableConstantHiveVarcharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveVarcharObjectInspector) {
        return ((WritableHiveVarcharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.startsWith(serdeConstants.CHAR_TYPE_NAME)) {

      // constant char projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveCharObjectInspector) {

        WritableConstantHiveCharObjectInspector wcsoi =
            (WritableConstantHiveCharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveCharObjectInspector) {
        return ((WritableHiveCharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME)) {

      // constant byte arrays
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        BytesWritable bw = ((BytesWritable) coi.getWritableConstantValue());
        return bw.getLength();
      } else if (oi instanceof WritableConstantBinaryObjectInspector) {

        // writable constant byte arrays
        WritableConstantBinaryObjectInspector wcboi = (WritableConstantBinaryObjectInspector) oi;
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    // Reject any clauses that are against a column that isn't the rowId mapping
    if (!this.hiveRowIdColumnName.equals(columnDesc.getColumn())) {
      return null;
    }

    ConstantObjectInspector objInspector = constantDesc.getWritableObjectInspector();

    Text constText;
    switch (rowIdMapping.getEncoding()) {
      case STRING:
        constText = getUtf8Value(objInspector);
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    PrimitiveTypeInfo hiveType = (PrimitiveTypeInfo) literal.getTypeInfo();
    RelDataType optiqDataType = TypeConverter.convert(hiveType, dtFactory);

    PrimitiveCategory hiveTypeCategory = hiveType.getPrimitiveCategory();

    ConstantObjectInspector coi = literal.getWritableObjectInspector();
    Object value = ObjectInspectorUtils.copyToStandardJavaObject(coi.getWritableConstantValue(),
        coi);

    RexNode optiqLiteral = null;
    // TODO: Verify if we need to use ConstantObjectInspector to unwrap data
    switch (hiveTypeCategory) {
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    if (colType.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {

      // constant string projection Ex: select "hello" from table
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantStringObjectInspector) {

        // some UDFs return writable constant strings (fixed width)
        // Ex: select upper("hello") from table
        WritableConstantStringObjectInspector wcsoi = (WritableConstantStringObjectInspector) oi;

        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableStringObjectInspector) {

        // some UDFs may emit strings of variable length. like pattern matching
        // UDFs. it's hard to find the length of such UDFs.
        // return the variable length from config
        return configVarLen;
      }
    } else if (colType.startsWith(serdeConstants.VARCHAR_TYPE_NAME)) {

      // constant varchar projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveVarcharObjectInspector) {

        WritableConstantHiveVarcharObjectInspector wcsoi =
            (WritableConstantHiveVarcharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveVarcharObjectInspector) {
        return ((WritableHiveVarcharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.startsWith(serdeConstants.CHAR_TYPE_NAME)) {

      // constant char projection
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        return coi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableConstantHiveCharObjectInspector) {

        WritableConstantHiveCharObjectInspector wcsoi =
            (WritableConstantHiveCharObjectInspector) oi;
        return wcsoi.getWritableConstantValue().toString().length();
      } else if (oi instanceof WritableHiveCharObjectInspector) {
        return ((WritableHiveCharObjectInspector) oi).getMaxLength();
      }
    } else if (colType.equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME)) {

      // constant byte arrays
      if (oi instanceof ConstantObjectInspector) {
        ConstantObjectInspector coi = (ConstantObjectInspector) oi;

        // if writable constant is null then return size 0
        if (coi.getWritableConstantValue() == null) {
          return 0;
        }

        BytesWritable bw = ((BytesWritable) coi.getWritableConstantValue());
        return bw.getLength();
      } else if (oi instanceof WritableConstantBinaryObjectInspector) {

        // writable constant byte arrays
        WritableConstantBinaryObjectInspector wcboi = (WritableConstantBinaryObjectInspector) oi;
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    if( arg0.length > 1) {
      if( !( arg0[1] instanceof ConstantObjectInspector)
          || !( arg0[1] instanceof StringObjectInspector) ){
        throw new UDFArgumentException("cast_array() takes a list, and an optional type to cast to.");
      }
      ConstantObjectInspector constInsp  = (ConstantObjectInspector) arg0[1];
      this.returnElemType =  constInsp.getWritableConstantValue().toString();
      this.toInspector = GetObjectInspectorForTypeName( returnElemType);
      ObjectInspector returnType = ObjectInspectorFactory.getStandardListObjectInspector(toInspector);
      return returnType;
    }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

         throw new UDFArgumentException("Usage : json_split( jsonstring, optional typestring) ");
       }
       if( !(arguments[1] instanceof ConstantObjectInspector) ) {
        throw new UDFArgumentException("Usage : json_split( jsonstring, typestring) : typestring must be constant");
       }
       ConstantObjectInspector typeInsp = (ConstantObjectInspector) arguments[1];
       String typeString = ((Text) typeInsp.getWritableConstantValue()).toString();
       TypeInfo valType = TypeInfoUtils.getTypeInfoFromTypeString(typeString);
      
       ObjectInspector valInsp = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(valType);
       ObjectInspector setInspector = ObjectInspectorFactory.getStandardListObjectInspector(valInsp);
       inspHandle = InspectorHandleFactory.GenerateInspectorHandle(setInspector);
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

            throw new UDFArgumentException("Usage : json_map( jsonstring, optional typestring) ");
        }
        if(!(arguments[1] instanceof ConstantObjectInspector)) {
            throw new UDFArgumentException("json_map( jsonstring, typestring ) : typestring must be a constant");
        }
        ConstantObjectInspector constInsp = (ConstantObjectInspector) arguments[1];
        String typeStr = ((Text) constInsp.getWritableConstantValue()).toString();
       
        String[] types = typeStr.split(",");
        if( types.length != 2) {
            throw new UDFArgumentException(" typestring must be of the form <keytype>,<valuetype>");
        }
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

      if( !(arg0[1] instanceof ConstantObjectInspector
        || !(arg0[1] instanceof StringObjectInspector)
        || !( arg0[0] instanceof PrimitiveObjectInspector)) {
        throw new UDFArgumentException( usage("2 arguments is eiter key and filename, or a filename and maptype"));
      }
          ConstantObjectInspector mapType = (ConstantObjectInspector)arg0[1];
      String typeStr = mapType.getWritableConstantValue().toString();
      try {
        //// able to parse map type ...
        MapObjectInspector mapInsp = getMapType( typeStr);
        keyType =  TypeInfoFactory.getPrimitiveTypeInfo( mapInsp.getMapKeyObjectInspector().getTypeName());
        valType =  TypeInfoFactory.getPrimitiveTypeInfo( mapInsp.getMapValueObjectInspector().getTypeName());
        fileNameInspector = (StringObjectInspector) arg0[0];
          return ObjectInspectorUtils.getStandardObjectInspector(mapInsp);
       
      } catch(UDFArgumentException checkMapType ) {
        /// Assume that it is key, filename
        this.keyInspector = (PrimitiveObjectInspector) arg0[0];
        keyType =  TypeInfoFactory.getPrimitiveTypeInfo( keyInspector.getTypeName());
        valType =  TypeInfoFactory.doubleTypeInfo;
        this.fileNameInspector = (StringObjectInspector) arg0[1];
        //// Default case is  string, double
        return PrimitiveObjectInspectorFactory.javaDoubleObjectInspector;
      }
    case 3:
      //// key , filename , maptype
      if( !( arg0[1] instanceof ConstantObjectInspector)
        || !( arg0[1] instanceof StringObjectInspector
          || !(arg0[2] instanceof ConstantObjectInspector)
        || !( arg0[2] instanceof StringObjectInspector)
        || !( arg0[0] instanceof PrimitiveObjectInspector)) {
        throw new UDFArgumentException( usage("3 arguments are key,filename and maptype"));
      }
      fileNameInspector = (StringObjectInspector) arg0[1];
     
      ConstantObjectInspector mapType3 = (ConstantObjectInspector)arg0[2];
      String typeStr3 = mapType3.getWritableConstantValue().toString();
      MapObjectInspector mapInspect = this.getMapType(typeStr3);
     
      keyInspector = (PrimitiveObjectInspector) arg0[0];
      if(keyInspector.getPrimitiveCategory() !=
        ((PrimitiveObjectInspector)mapInspect.getMapKeyObjectInspector() ).getPrimitiveCategory() ) {
View Full Code Here

Examples of org.apache.hadoop.hive.serde2.objectinspector.ConstantObjectInspector

    if( arg0[1].getCategory() == Category.PRIMITIVE
            && ((PrimitiveObjectInspector)arg0[1]).getPrimitiveCategory() == PrimitiveCategory.STRING) {
        if( !( arg0[1] instanceof ConstantObjectInspector) ) {
           throw new UDFArgumentException("typeinfo string must be constant");
        }
        ConstantObjectInspector typeInsp = (ConstantObjectInspector) arg0[1];
       
        String typeStr = typeInsp.getWritableConstantValue().toString();
        inspHandle = InspectorHandle.InspectorHandleFactory.GenerateInspectorHandleFromTypeInfo(typeStr);
    } else {
      inspHandle = InspectorHandle.InspectorHandleFactory.GenerateInspectorHandle( arg0[1]);
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.