Java Code Examples for org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory#writableFloatObjectInspector()

The following examples show how to use org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory#writableFloatObjectInspector() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private ObjectInspector getObjectInspector(final TypeInfo typeInfo) {
    if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.dateTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    } else {
        throw new UnsupportedOperationException("Unknown field type: " + typeInfo);
    }
}
 
Example 2
@Override
public ObjectInspector initialize(@Nonnull ObjectInspector[] argOIs)
        throws UDFArgumentException {
    if (argOIs.length != 1) {
        throw new UDFArgumentException("_FUNC_ takes 1 argument");
    }
    this.argOI = HiveUtils.asDoubleCompatibleOI(argOIs[0]);
    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 3
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("angular_similarity takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 4
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("euclid_similarity takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 5
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 1) {
        throw new UDFArgumentException("distance2similarity takes 1 argument");
    }
    this.distanceOI = HiveUtils.asDoubleCompatibleOI(argOIs, 0);
    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 6
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("cosine_similarity takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 7
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 3) {
        throw new UDFArgumentException("minkowski_distance takes 3 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);
    this.order_p = HiveUtils.getAsConstDouble(argOIs[2]);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 8
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("euclid_distance takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs[0]);
    this.arg1ListOI = HiveUtils.asListOI(argOIs[1]);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 9
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("cosine_distance takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs[0]);
    this.arg1ListOI = HiveUtils.asListOI(argOIs[1]);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 10
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("manhattan_distance takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 11
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 2) {
        throw new UDFArgumentException("angular_distance takes 2 arguments");
    }
    this.arg0ListOI = HiveUtils.asListOI(argOIs, 0);
    this.arg1ListOI = HiveUtils.asListOI(argOIs, 1);

    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
}
 
Example 12
private ObjectInspector getObjectInspector(final TypeInfo typeInfo) {
  if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
    return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
  } else if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetStringInspector;
  } else if (typeInfo.getCategory().equals(Category.STRUCT)) {
    return new ArrayWritableObjectInspector((StructTypeInfo) typeInfo);
  } else if (typeInfo.getCategory().equals(Category.LIST)) {
    final TypeInfo subTypeInfo = ((ListTypeInfo) typeInfo).getListElementTypeInfo();
    return new ParquetHiveArrayInspector(getObjectInspector(subTypeInfo));
  } else if (typeInfo.getCategory().equals(Category.MAP)) {
    final TypeInfo keyTypeInfo = ((MapTypeInfo) typeInfo).getMapKeyTypeInfo();
    final TypeInfo valueTypeInfo = ((MapTypeInfo) typeInfo).getMapValueTypeInfo();
    if (keyTypeInfo.equals(TypeInfoFactory.stringTypeInfo) || keyTypeInfo.equals(TypeInfoFactory.byteTypeInfo)
            || keyTypeInfo.equals(TypeInfoFactory.shortTypeInfo)) {
      return new DeepParquetHiveMapInspector(getObjectInspector(keyTypeInfo), getObjectInspector(valueTypeInfo));
    } else {
      return new StandardParquetHiveMapInspector(getObjectInspector(keyTypeInfo), getObjectInspector(valueTypeInfo));
    }
  } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
    throw new UnsupportedOperationException("timestamp not implemented yet");
  } else if (typeInfo.equals(TypeInfoFactory.byteTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetByteInspector;
  } else if (typeInfo.equals(TypeInfoFactory.shortTypeInfo)) {
    return ParquetPrimitiveInspectorFactory.parquetShortInspector;
  } else {
    throw new IllegalArgumentException("Unknown field info: " + typeInfo);
  }

}
 
Example 13
public static ObjectInspector createWritableObjectInspector(int columnId,
                                             List<OrcProto.Type> types){
  OrcProto.Type type = types.get(columnId);
  switch (type.getKind()) {
    case FLOAT:
      return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
    case DOUBLE:
      return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    case BOOLEAN:
      return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    case BYTE:
      return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
    case SHORT:
      return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
    case INT:
      return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    case LONG:
      return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
    case BINARY:
      return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
    case STRING:
      return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    case TIMESTAMP:
      return PrimitiveObjectInspectorFactory.javaTimestampObjectInspector;
    case STRUCT:
      return new OrcStruct.OrcStructInspector(columnId, types);
    case UNION:
      return new OrcUnion.OrcUnionObjectInspector(columnId, types);
    case MAP:
      return new OrcStruct.OrcMapObjectInspector(columnId, types);
    case LIST:
      return new OrcStruct.OrcListObjectInspector(columnId, types);
    default:
      throw new UnsupportedOperationException("Unknown type " +
        type.getKind());
  }
}
 
Example 14
public static ObjectInspector craeteObjectInspectorFromTypeInfo( final TypeInfo typeInfo ){
  switch ( typeInfo.getCategory() ){
    case STRUCT:
      return new MDSStructObjectInspector( (StructTypeInfo)typeInfo );
    case MAP:
      return new MDSMapObjectInspector( (MapTypeInfo)typeInfo );
    case LIST:
      return new MDSListObjectInspector( (ListTypeInfo)typeInfo );
    case UNION:
      UnionTypeInfo unionTypeInfo = (UnionTypeInfo)typeInfo;
      List<ObjectInspector> unionList = new ArrayList<ObjectInspector>();
      for( TypeInfo childTypeInfo : unionTypeInfo.getAllUnionObjectTypeInfos() ){
        unionList.add( craeteObjectInspectorFromTypeInfo( childTypeInfo ) );
      }
      return ObjectInspectorFactory.getStandardUnionObjectInspector( unionList );
    case PRIMITIVE:
      PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo)typeInfo;
      switch( primitiveTypeInfo.getPrimitiveCategory() ){
        case STRING:
          return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
        case BINARY:
          return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
        case BOOLEAN:
          return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
        case BYTE:
          return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
        case DOUBLE:
          return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
        case FLOAT:
          return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
        case INT:
          return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
        case LONG:
          return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
        case SHORT:
          return PrimitiveObjectInspectorFactory.writableShortObjectInspector;

        case DATE:
        case DECIMAL:
        case TIMESTAMP:
        case VOID:
        default:
        throw new UnsupportedOperationException( "Unknown primitive category " + primitiveTypeInfo.getPrimitiveCategory() );
      }
    default:
      throw new UnsupportedOperationException( "Unknown category " + typeInfo.getCategory() );
  }
}
 
Example 15
public static ObjectInspector createWritableObjectInspector(TypeInfo info) {
  switch (info.getCategory()) {
    case PRIMITIVE:
      switch (((PrimitiveTypeInfo) info).getPrimitiveCategory()) {
        case FLOAT:
          return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
        case DOUBLE:
          return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
        case BOOLEAN:
          return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
        case BYTE:
          return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
        case SHORT:
          return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
        case INT:
          return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
        case LONG:
          return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
        case BINARY:
          return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
        case STRING:
          return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
        case TIMESTAMP:
          return PrimitiveObjectInspectorFactory.javaTimestampObjectInspector;
        default:
          throw new IllegalArgumentException("Unknown primitive type " +
            ((PrimitiveTypeInfo) info).getPrimitiveCategory());
      }
    case STRUCT:
      return new OrcStruct.OrcStructInspector((StructTypeInfo) info);
    case UNION:
      return new OrcUnion.OrcUnionObjectInspector((UnionTypeInfo) info);
    case MAP:
      return new OrcStruct.OrcMapObjectInspector((MapTypeInfo) info);
    case LIST:
      return new OrcStruct.OrcListObjectInspector((ListTypeInfo) info);
    default:
      throw new IllegalArgumentException("Unknown type " +
        info.getCategory());
  }
}