Spark Streaming:updateStateByKey报错 is not applicable for the arguments...

ones.updateStateByKey(new Function2<List<Integer>, Optional<Integer>, Optional<Integer>>() {
            @Override
            public Optional<Integer> call(List<Integer> arg0, Optional<Integer> arg1) throws Exception {
                // TODO Auto-generated method stub
                return null;
            }
        });

对JavaPairDStream<String, Integer> ones使用updateStateByKey报错:

The method updateStateByKey(Function2<List<Integer>,Optional<S>,Optional<S>>) in the type JavaPairDStream<String,Integer> is not applicable for the arguments (new Function2<List<Integer>,Optional<Integer>,Optional<Integer>>(){})

 

解决办法:很可能是Optional导包导错了,要导com.google.common.base.Optional

posted @ 2019-06-19 16:32  梦醒江南·Infinite  阅读(2275)  评论(0)    收藏  举报