Apache Accark에서 사용자 정의 누산기를 사용하여 세트에 누적하려고합니다. 결과에는 Set [String] 유형이 있어야합니다. 이것에 대한 나는 사용자 정의 accumulator를 creat :사용자 정의 집합 누산기를 만드는 방법, 즉 [문자열]을 설정 하시겠습니까?
object SetAccumulatorParam extends AccumulatorParam[Set[String]] {
def addInPlace(r1: mutable.Set[String], r2: mutable.Set[String]): mutable.Set[String] = {
r1 ++= r2
}
def zero(initialValue: mutable.Set[String]): mutable.Set[String] = {
Set()
}
}
그러나이 유형의 변수를 인스턴스화 할 수 없습니다.
val tags = sc.accumulator(Set(""))(SetAccumulatorParam)
오류가 발생합니다. 도움을 청하십시오. 1.6
는required: org.apache.spark.AccumulatorParam[Set[String]]
은 공식 문서 (HTTP 상당히 다른 보인다. org/docs/latest/programming-guide.html # accumulators). 또한 Spark이이 누적기를 인스턴스화하려고한다고 가정 할 때 여기 개체의 사용법에 대해 회의적입니다. – LiMuBei