当前位置: 首页>>代码示例>>Java>>正文


Java UDFArgumentTypeException类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException的典型用法代码示例。如果您正苦于以下问题:Java UDFArgumentTypeException类的具体用法?Java UDFArgumentTypeException怎么用?Java UDFArgumentTypeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UDFArgumentTypeException类属于org.apache.hadoop.hive.ql.exec包,在下文中一共展示了UDFArgumentTypeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkArgumentTypes

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
private static void checkArgumentTypes(TypeInfo[] parameters) throws UDFArgumentTypeException {
  if (parameters.length != 2) {
    throw new UDFArgumentTypeException(parameters.length - 1,
        "Exactly two arguments are expected.");
  }

  if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
    throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
        + parameters[0].getTypeName() + " is passed.");
  }

  if (parameters[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
    throw new UDFArgumentTypeException(1, "Only primitive type arguments are accepted but "
        + parameters[1].getTypeName() + " is passed.");
  }

  if (!acceptedPrimitiveCategory(((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory())) {
    throw new UDFArgumentTypeException(0, "Only numeric type arguments are accepted but "
        + parameters[0].getTypeName() + " is passed.");

  }
  if (!acceptedPrimitiveCategory(((PrimitiveTypeInfo) parameters[1]).getPrimitiveCategory())) {
    throw new UDFArgumentTypeException(1, "Only numeric type arguments are accepted but "
        + parameters[1].getTypeName() + " is passed.");
  }
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:27,代码来源:GenericUDAFBinarySetFunctions.java

示例2: checkArgGroups

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static void checkArgGroups(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, PrimitiveGrouping... grps)
        throws UDFArgumentTypeException {
    PrimitiveCategory inputType = ((PrimitiveObjectInspector) arguments[i]).getPrimitiveCategory();
    for (PrimitiveGrouping grp : grps) {
        if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputType) == grp) {
            inputTypes[i] = inputType;
            return;
        }
    }
    // build error message
    StringBuilder sb = new StringBuilder();
    sb.append("_FUNC_ only takes ");
    sb.append(grps[0]);
    for (int j = 1; j < grps.length; j++) {
        sb.append(", ");
        sb.append(grps[j]);
    }
    sb.append(" types as ");
    sb.append(getArgOrder(i));
    sb.append(" argument, got ");
    sb.append(inputType);
    throw new UDFArgumentTypeException(i, sb.toString());
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:25,代码来源:BackportUtils.java

示例3: obtainIntConverter

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static void obtainIntConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    switch (inputType) {
        case BYTE:
        case SHORT:
        case INT:
        case VOID:
            break;
        default:
            throw new UDFArgumentTypeException(i, "_FUNC_ only takes INT/SHORT/BYTE types as "
                    + getArgOrder(i) + " argument, got " + inputType);
    }

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableIntObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:21,代码来源:BackportUtils.java

示例4: obtainLongConverter

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static void obtainLongConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    switch (inputType) {
        case BYTE:
        case SHORT:
        case INT:
        case LONG:
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes LONG/INT/SHORT/BYTE types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableIntObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java

示例5: obtainDateConverter

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static void obtainDateConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    ObjectInspector outOi;
    switch (inputType) {
        case STRING:
        case VARCHAR:
        case CHAR:
            outOi = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
            break;
        case TIMESTAMP:
        case DATE:
        case VOID:
            outOi = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }
    converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:25,代码来源:BackportUtils.java

示例6: obtainTimestampConverter

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static void obtainTimestampConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    ObjectInspector outOi;
    switch (inputType) {
        case STRING:
        case VARCHAR:
        case CHAR:
        case TIMESTAMP:
        case DATE:
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }
    outOi = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
    converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java

示例7: getConstantIntValue

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
public static Integer getConstantIntValue(ObjectInspector[] arguments, int i)
        throws UDFArgumentTypeException {
    Object constValue = ((ConstantObjectInspector) arguments[i]).getWritableConstantValue();
    if (constValue == null) {
        return null;
    }
    int v;
    if (constValue instanceof IntWritable) {
        v = ((IntWritable) constValue).get();
    } else if (constValue instanceof ShortWritable) {
        v = ((ShortWritable) constValue).get();
    } else if (constValue instanceof ByteWritable) {
        v = ((ByteWritable) constValue).get();
    } else {
        throw new UDFArgumentTypeException(i, "_FUNC_ only takes INT/SHORT/BYTE types as "
                + getArgOrder(i) + " argument, got " + constValue.getClass());
    }
    return v;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:20,代码来源:BackportUtils.java

示例8: initialize

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 1) {
        throw new UDFArgumentLengthException(
            "add_feature_index() has an single arguments: array<double> features");
    }

    switch (arguments[0].getCategory()) {
        case LIST:
            argumentOI = (ListObjectInspector) arguments[0];
            ObjectInspector elmOI = argumentOI.getListElementObjectInspector();
            if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
                if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.DOUBLE) {
                    break;
                }
            }
        default:
            throw new UDFArgumentTypeException(0, "Type mismatch: features");
    }

    return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:AddFeatureIndexUDFWrapper.java

示例9: initialize

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 1) {
        throw new UDFArgumentLengthException(
            "add_bias() has an single arguments: array<string> features");
    }

    switch (arguments[0].getCategory()) {
        case LIST:
            argumentOI = (ListObjectInspector) arguments[0];
            ObjectInspector elmOI = argumentOI.getListElementObjectInspector();
            if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
                if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.STRING) {
                    break;
                }
            }
        default:
            throw new UDFArgumentTypeException(0, "Type mismatch: features");
    }

    return ObjectInspectorFactory.getStandardListObjectInspector(argumentOI.getListElementObjectInspector());
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:AddBiasUDFWrapper.java

示例10: getEvaluator

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(@Nonnull TypeInfo[] typeInfo) throws SemanticException {
    if (typeInfo.length != 2 && typeInfo.length != 3) {
        throw new UDFArgumentTypeException(typeInfo.length - 1,
            "_FUNC_ takes two or three arguments");
    }

    ListTypeInfo arg1type = HiveUtils.asListTypeInfo(typeInfo[0]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg1type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(0,
            "The first argument `array rankItems` is invalid form: " + typeInfo[0]);
    }
    ListTypeInfo arg2type = HiveUtils.asListTypeInfo(typeInfo[1]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg2type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(1,
            "The second argument `array correctItems` is invalid form: " + typeInfo[1]);
    }

    return new HitRateUDAF.Evaluator();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:21,代码来源:HitRateUDAF.java

示例11: getEvaluator

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(@Nonnull TypeInfo[] typeInfo) throws SemanticException {
    if (typeInfo.length != 2 && typeInfo.length != 3) {
        throw new UDFArgumentTypeException(typeInfo.length - 1,
            "_FUNC_ takes two or three arguments");
    }

    ListTypeInfo arg1type = HiveUtils.asListTypeInfo(typeInfo[0]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg1type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(0,
            "The first argument `array rankItems` is invalid form: " + typeInfo[0]);
    }
    ListTypeInfo arg2type = HiveUtils.asListTypeInfo(typeInfo[1]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg2type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(1,
            "The second argument `array correctItems` is invalid form: " + typeInfo[1]);
    }

    return new Evaluator();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:21,代码来源:MRRUDAF.java

示例12: getEvaluator

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(@Nonnull TypeInfo[] typeInfo) throws SemanticException {
    if (typeInfo.length != 2 && typeInfo.length != 3) {
        throw new UDFArgumentTypeException(typeInfo.length - 1,
            "_FUNC_ takes two or three arguments");
    }

    if (HiveUtils.isNumberTypeInfo(typeInfo[0]) && HiveUtils.isIntegerTypeInfo(typeInfo[1])) {
        return new ClassificationEvaluator();
    } else {
        ListTypeInfo arg1type = HiveUtils.asListTypeInfo(typeInfo[0]);
        if (!HiveUtils.isPrimitiveTypeInfo(arg1type.getListElementTypeInfo())) {
            throw new UDFArgumentTypeException(0,
                "The first argument `array rankItems` is invalid form: " + typeInfo[0]);
        }

        ListTypeInfo arg2type = HiveUtils.asListTypeInfo(typeInfo[1]);
        if (!HiveUtils.isPrimitiveTypeInfo(arg2type.getListElementTypeInfo())) {
            throw new UDFArgumentTypeException(1,
                "The second argument `array correctItems` is invalid form: " + typeInfo[1]);
        }

        return new RankingEvaluator();
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:AUCUDAF.java

示例13: getEvaluator

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(@Nonnull TypeInfo[] typeInfo) throws SemanticException {
    if (typeInfo.length != 2 && typeInfo.length != 3) {
        throw new UDFArgumentTypeException(typeInfo.length - 1,
            "_FUNC_ takes two or three arguments");
    }

    ListTypeInfo arg1type = HiveUtils.asListTypeInfo(typeInfo[0]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg1type.getListElementTypeInfo())
            && !HiveUtils.isStructTypeInfo(arg1type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(0,
            "The first argument `array rankItems` is invalid form: " + typeInfo[0]);
    }
    ListTypeInfo arg2type = HiveUtils.asListTypeInfo(typeInfo[1]);
    if (!HiveUtils.isPrimitiveTypeInfo(arg2type.getListElementTypeInfo())) {
        throw new UDFArgumentTypeException(1,
            "The second argument `array correctItems` is invalid form: " + typeInfo[1]);
    }

    return new Evaluator();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:NDCGUDAF.java

示例14: asIntCompatibleOI

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Nonnull
public static PrimitiveObjectInspector asIntCompatibleOI(@Nonnull final ObjectInspector argOI)
        throws UDFArgumentTypeException {
    if (argOI.getCategory() != Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
                + argOI.getTypeName() + " is passed.");
    }
    final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
    switch (oi.getPrimitiveCategory()) {
        case INT:
        case SHORT:
        case LONG:
        case FLOAT:
        case DOUBLE:
        case DECIMAL:
        case BOOLEAN:
        case BYTE:
        case STRING:
            break;
        default:
            throw new UDFArgumentTypeException(0, "Unxpected type '" + argOI.getTypeName()
                    + "' is passed.");
    }
    return oi;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:HiveUtils.java

示例15: asLongCompatibleOI

import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException; //导入依赖的package包/类
@Nonnull
public static PrimitiveObjectInspector asLongCompatibleOI(@Nonnull final ObjectInspector argOI)
        throws UDFArgumentTypeException {
    if (argOI.getCategory() != Category.PRIMITIVE) {
        throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
                + argOI.getTypeName() + " is passed.");
    }
    final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
    switch (oi.getPrimitiveCategory()) {
        case LONG:
        case INT:
        case SHORT:
        case BYTE:
        case BOOLEAN:
        case FLOAT:
        case DOUBLE:
        case DECIMAL:
        case STRING:
        case TIMESTAMP:
            break;
        default:
            throw new UDFArgumentTypeException(0, "Unxpected type '" + argOI.getTypeName()
                    + "' is passed.");
    }
    return oi;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:HiveUtils.java


注:本文中的org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。