2017-12-04 14 views
-1

저는 아파치 스파크를 배우고 스칼라 터미널에서 작은 프로그램을 실행하려고합니다.오류를 해결하는 방법 : 값 reduceByKey is org.apache.spark.rdd.RDD [(Int, Int)]의 멤버가 아닙니까?

나는 다음과 같은 명령을 사용하여 DFS, 원사, 역사 서버를 시작

:

start-dfs.sh 
start-yarn.sh 
mr-jobhistory-deamon.sh start historyserver 

다음 스칼라 터미널에서, 내가 쓴 다음 명령을

var file = sc.textFile("/Users/****/Documents/backups/h/*****/input/ncdc/micro-tab/sample.txt"); 
val records = lines.map(_.split("\t")); 
val filters = records.filter(rec => (rec(1) != "9999" && rec(2).matches("[01459]"))); 
val tuples = filters.map(rec => (rec(0).toInt, rec(1).toInt)); 
val maxTemps = tuples.reduceByKey((a,b) => Math.max(a,b)); 

모든 명령이를 마지막 오류를 제외하고 성공적으로 실행됩니다. 다음 오류가 throw됩니다.

error: value reduceByKey is not a member of org.apache.spark.rdd.RDD[(Int, Int)] 

몇 가지 해결책을 찾았습니다.

This comes from using a pair rdd function generically. The reduceByKey method is actually a method of the PairRDDFunctions class, which has an implicit conversion from RDD.So it requires several implicit typeclasses. Normally when working with simple concrete types, those are already in scope. But you should be able to amend your method to also require those same implicit.

그러나 이것을 달성하는 방법은 확실하지 않습니다.

어떤 도움,이 문제를 해결하는 방법?

+1

[reduceByKey 값은 org.apache.spark.rdd.RDD의 멤버가 아닙니다.] (https://stackoverflow.com/questions/45620797/value-reducebykey-is-not-a-member-of) -org-apache-spark-rdd-rdd) –

+1

오류를 재현 할 수 없습니다. 사용중인 스파크의 버전과 함께 MVCE를 추가 하시겠습니까? – eliasah

답변

1

가져 오기가 누락 된 것 같습니다. 콘솔에 다음과 같이 작성하십시오.

import org.apache.spark.SparkContext._ 

위의 명령을 실행하십시오. 이 가져 오기는 reduceByKey 메소드를 사용할 수있는 암시 적 변환을 가져옵니다.