java—如何在具有多个参数的配置单元中编写udaf

67up9zun  于 2021-06-02  发布在  Hadoop
关注(0)|答案(0)|浏览(338)

我想在hive中编写一个udaf,它可以接受多个参数。下面是一些类代码架构,在其中我删除了方法中的实际逻辑,因为这只会占用空间

public class CountWithRating extends UDAF{

    public static class MovieCountWithGivenRating implements UDAFEvaluator{
        public static class PartialClass{
            Set users;
            Map movieMap; // contains movieIds , number of users which give the eq or more then given rating
        }
        private PartialClass partial;

        public void init(){
            partial = null;
        }

        public boolean iterate(IntWritable userId,IntWritable movieId,Text rating,DoubleWritable static_rating){

        }

        public PartialClass terminatePartial(){
            return partial;
        }

        public boolean merge(PartialClass other){
            return true;
        }

        public IntWritable terminate(){

        }

    }

}

在本文中,我在hive中创建了如下函数

CREATE TEMPORARY FUNCTION MaxMovieCount AS 'hive.udaf.CountWithRating';

并调用如下函数

select MaxMovieCount(userId,movieId,rating,4.0) from rating;

但它给出的误差如下

FAILED: NoMatchingMethodException No matching method for class hive.udaf.CountWithRating with (int, int, string, double). Possible choices: _FUNC_(int, int, string, struct)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题