• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GenericUDAFEvaluator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的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


示例2: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的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


示例3: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的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


示例4: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的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


示例5: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info)
        throws SemanticException {
    final ObjectInspector[] OIs = info.getParameterObjectInspectors();

    if (OIs.length != 2) {
        throw new UDFArgumentLengthException("Specify two arguments: " + OIs.length);
    }
    if (!HiveUtils.isNumberListOI(OIs[0])) {
        throw new UDFArgumentTypeException(0,
            "Only array<number> type argument is acceptable but " + OIs[0].getTypeName()
                    + " was passed as `features`");
    }
    if (!HiveUtils.isListOI(OIs[1])
            || !HiveUtils.isIntegerOI(((ListObjectInspector) OIs[1]).getListElementObjectInspector())) {
        throw new UDFArgumentTypeException(1,
            "Only array<int> type argument is acceptable but " + OIs[1].getTypeName()
                    + " was passed as `labels`");
    }

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


示例6: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(@Nonnull TypeInfo[] argTypes) throws SemanticException {
    final int numFeatures = argTypes.length;
    if (numFeatures == 0) {
        throw new UDFArgumentException("_FUNC_ requires at least 1 argument");
    }
    for (int i = 0; i < numFeatures; i++) {
        if (argTypes[i] == null) {
            throw new UDFArgumentTypeException(i,
                "Null type is found. Only primitive type arguments are accepted.");
        }
        if (argTypes[i].getCategory() != ObjectInspector.Category.PRIMITIVE) {
            throw new UDFArgumentTypeException(i,
                "Only primitive type arguments are accepted but " + argTypes[i].getTypeName()
                        + " was passed as parameter 1.");
        }
    }

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


示例7: getEvaluator

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info)
        throws SemanticException {
    ObjectInspector[] OIs = info.getParameterObjectInspectors();

    if (OIs.length != 2) {
        throw new UDFArgumentLengthException("Specify two arguments.");
    }

    if (!HiveUtils.isNumberListOI(OIs[0])) {
        throw new UDFArgumentTypeException(0,
            "Only array<number> type argument is acceptable but " + OIs[0].getTypeName()
                    + " was passed as `matrix0_row`");
    }

    if (!HiveUtils.isNumberListOI(OIs[1])) {
        throw new UDFArgumentTypeException(1,
            "Only array<number> type argument is acceptable but " + OIs[1].getTypeName()
                    + " was passed as `matrix1_row`");
    }

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


示例8: testMidAUC

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testMidAUC() throws Exception {
    final double[] scores = new double[] {0.8, 0.7, 0.5, 0.3, 0.2};

    // if TP and FP appear alternately, AUC=0.5
    final int[] labels1 = new int[] {1, 0, 1, 0, 1};
    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);
    for (int i = 0; i < scores.length; i++) {
        evaluator.iterate(agg, new Object[] {scores[i], labels1[i]});
    }
    Assert.assertEquals(0.5, agg.get(), 1e-5);

    final int[] labels2 = new int[] {0, 1, 0, 1, 0};
    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);
    for (int i = 0; i < scores.length; i++) {
        evaluator.iterate(agg, new Object[] {scores[i], labels2[i]});
    }
    Assert.assertEquals(0.5, agg.get(), 1e-5);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:AUCUDAFTest.java


示例9: test100

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void test100() throws Exception {
    final double[] scores = new double[] {0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.8, 0.8,
            0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8, 0.7, 0.7, 0.7, 0.7,
            0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.6, 0.6, 0.6,
            0.6, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.4, 0.4, 0.4, 0.4,
            0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
            0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.1,
            0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1};
    final int[] labels = new int[] {1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
            0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1,
            1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,
            1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0};

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < scores.length; i++) {
        evaluator.iterate(agg, new Object[] {scores[i], labels[i]});
    }

    // should equal to scikit-learn's result
    Assert.assertEquals(0.567226890756, agg.get(), 1e-5);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:25,代码来源:AUCUDAFTest.java


示例10: testBinaryMultiSamplesAverageBinary

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testBinaryMultiSamplesAverageBinary() throws Exception {
    final int[] actual = {0, 1, 0, 0, 0, 1, 0, 0};
    final int[] predicted = {1, 0, 0, 1, 0, 1, 0, 1};
    double beta = 1.;
    String average = "binary";
    binarySetUp(actual[0], predicted[0], beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    // should equal to turi's result
    // https://turi.com/learn/userguide/evaluation/classification.html#fscores-f1-fbeta-
    Assert.assertEquals(0.3333d, agg.get(), 1e-4);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:20,代码来源:FMeasureUDAFTest.java


示例11: testBinaryMultiSamplesAverageMacro

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test(expected = HiveException.class)
public void testBinaryMultiSamplesAverageMacro() throws Exception {
    final int[] actual = {0, 1, 0, 0, 0, 1, 0, 0};
    final int[] predicted = {1, 0, 0, 1, 0, 1, 0, 1};
    double beta = 1.;
    String average = "macro";
    binarySetUp(actual[0], predicted[0], beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    agg.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:FMeasureUDAFTest.java


示例12: testBinaryMultiSamples

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testBinaryMultiSamples() throws Exception {
    final int[] actual = {0, 1, 0, 0, 0, 1, 0, 0};
    final int[] predicted = {1, 0, 0, 1, 0, 1, 0, 1};
    double beta = 1.;
    String average = "micro";
    binarySetUp(actual[0], predicted[0], beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    Assert.assertEquals(0.5d, agg.get(), 1e-4);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:FMeasureUDAFTest.java


示例13: testBinaryMultiSamplesBeta2

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testBinaryMultiSamplesBeta2() throws Exception {
    final int[] actual = {0, 1, 0, 0, 0, 1, 0, 0};
    final int[] predicted = {1, 0, 0, 1, 0, 1, 0, 1};
    double beta = 2.0;
    String average = "binary";
    binarySetUp(actual[0], predicted[0], beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    Assert.assertEquals(0.4166d, agg.get(), 1e-4);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:FMeasureUDAFTest.java


示例14: testMultiLabelNegativeBeta

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test(expected = HiveException.class)
public void testMultiLabelNegativeBeta() throws Exception {
    List<Integer> actual = Arrays.asList(1, 3, 2, 6);
    List<Integer> predicted = Arrays.asList(1, 2, 4);
    double beta = -1.0d;
    String average = "micro";
    setUpWithArguments(beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    evaluator.iterate(agg, new Object[] {actual, predicted});

    // FMeasure for beta has negative value is not defined
    agg.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:17,代码来源:FMeasureUDAFTest.java


示例15: testMultiLabelF1score

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testMultiLabelF1score() throws Exception {
    List<Integer> actual = Arrays.asList(1, 3, 2, 6);
    List<Integer> predicted = Arrays.asList(1, 2, 4);
    double beta = 1.0;
    String average = " micro";
    setUpWithArguments(beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    evaluator.iterate(agg, new Object[] {actual, predicted});

    // should equal to spark's micro f1 measure result
    // https://spark.apache.org/docs/latest/mllib-evaluation-metrics.html#multilabel-classification
    Assert.assertEquals(0.5714285714285714, agg.get(), 1e-5);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:FMeasureUDAFTest.java


示例16: testMultiLabelF1MultiSamples

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testMultiLabelF1MultiSamples() throws Exception {
    String[][] actual = { {"0", "2"}, {"0", "1"}, {"0"}, {"2"}, {"2", "0"}, {"0", "1"},
            {"1", "2"}};
    String[][] predicted = { {"0", "1"}, {"0", "2"}, {}, {"2"}, {"2", "0"}, {"0", "1", "2"},
            {"1"}};

    double beta = 1.0;
    String average = "micro";
    setUpWithArguments(beta, average);

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    // should equal to spark's micro f1 measure result
    // https://spark.apache.org/docs/latest/mllib-evaluation-metrics.html#multilabel-classification
    Assert.assertEquals(0.6956d, agg.get(), 1e-4);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:FMeasureUDAFTest.java


示例17: testMultiLabelFmeasureMultiSamples

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testMultiLabelFmeasureMultiSamples() throws Exception {
    String[][] actual = { {"0", "2"}, {"0", "1"}, {"0"}, {"2"}, {"2", "0"}, {"0", "1"},
            {"1", "2"}};
    String[][] predicted = { {"0", "1"}, {"0", "2"}, {}, {"2"}, {"2", "0"}, {"0", "1", "2"},
            {"1"}};

    double beta = 2.0;
    String average = "micro";
    setUpWithArguments(beta, average);
    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    Assert.assertEquals(0.6779d, agg.get(), 1e-4);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:20,代码来源:FMeasureUDAFTest.java


示例18: testMultiLabelFmeasureBinary

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test(expected = HiveException.class)
public void testMultiLabelFmeasureBinary() throws Exception {
    String[][] actual = { {"0", "2"}, {"0", "1"}, {"0"}, {"2"}, {"2", "0"}, {"0", "1"},
            {"1", "2"}};
    String[][] predicted = { {"0", "1"}, {"0", "2"}, {}, {"2"}, {"2", "0"}, {"0", "1", "2"},
            {"1"}};

    double beta = 1.0;
    String average = "binary";

    setUpWithArguments(beta, average);
    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < actual.length; i++) {
        evaluator.iterate(agg, new Object[] {actual[i], predicted[i]});
    }

    agg.get();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:21,代码来源:FMeasureUDAFTest.java


示例19: test

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void test() throws Exception {
    final TransposeAndDotUDAF tad = new TransposeAndDotUDAF();

    final double[][] matrix0 = new double[][] { {1, -2}, {-1, 3}};
    final double[][] matrix1 = new double[][] { {1, 2}, {3, 4}};

    final ObjectInspector[] OIs = new ObjectInspector[] {
            ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector),
            ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector)};
    final GenericUDAFEvaluator evaluator = tad.getEvaluator(new SimpleGenericUDAFParameterInfo(
        OIs, false, false));
    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, OIs);
    TransposeAndDotUDAF.TransposeAndDotUDAFEvaluator.TransposeAndDotAggregationBuffer agg = (TransposeAndDotUDAF.TransposeAndDotUDAFEvaluator.TransposeAndDotAggregationBuffer) evaluator.getNewAggregationBuffer();
    evaluator.reset(agg);
    for (int i = 0; i < matrix0.length; i++) {
        evaluator.iterate(agg, new Object[] {WritableUtils.toWritableList(matrix0[i]),
                WritableUtils.toWritableList(matrix1[i])});
    }

    final double[][] answer = new double[][] { {-2.0, -2.0}, {7.0, 8.0}};

    for (int i = 0; i < answer.length; i++) {
        Assert.assertArrayEquals(answer[i], agg.aggMatrix[i], 0.d);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:TransposeAndDotUDAFTest.java


示例20: testNaturalOrder

import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator; //导入依赖的package包/类
@Test
public void testNaturalOrder() throws Exception {
    ObjectInspector[] inputOIs = new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaDoubleObjectInspector};

    final String[] values = new String[] {"banana", "apple", "candy"};

    evaluator.init(GenericUDAFEvaluator.Mode.PARTIAL1, inputOIs);
    evaluator.reset(agg);

    for (int i = 0; i < values.length; i++) {
        evaluator.iterate(agg, new Object[] {values[i]});
    }

    List<Object> res = evaluator.terminate(agg);

    Assert.assertEquals(3, res.size());
    Assert.assertEquals("apple", res.get(0));
    Assert.assertEquals("banana", res.get(1));
    Assert.assertEquals("candy", res.get(2));
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:21,代码来源:UDAFToOrderedListTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DerbyDialect类代码示例发布时间:2022-05-22
下一篇:
Java NibbleUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap