그래서 stackoverflow 사용자베이스의 샘플 인 큰 데이터 세트가 있습니다. 다음과 같이 데이터 세트에서 한 줄은 다음과 같습니다Scala/Spark에서 RDD로부터 데이터 추출하기
<row Id="42" Reputation="11849" CreationDate="2008-08-01T13:00:11.640" DisplayName="Coincoin" LastAccessDate="2014-01-18T20:32:32.443" WebsiteUrl="" Location="Montreal, Canada" AboutMe="A guy with the attention span of a dead goldfish who has been having a blast in the industry for more than 10 years.

Mostly specialized in game and graphics programming, from custom software 3D renderers to accelerated hardware pipeline programming." Views="648" UpVotes="337" DownVotes="40" Age="35" AccountId="33" />
나는 그것이 "35"나는 것입니다 그것은이 예에서는 "11849"이고 세부터 수,이 경우 평판에서 숫자를 추출하고 싶습니다 부유물처럼 보이기를 좋아합니다. 이 파일은 HDFS에 위치한
그래서 내가 인용으로 분할 할 때 RDD가
val linesWithAge = lines.filter(line => line.contains("Age=")) //This is filtering data which doesnt have age
val repSplit = linesWithAge.flatMap(line => line.split("\"")) //Here I am trying to split the data where there is a "
그래서 명성 지수 23 인덱스 세 나이에 표시하는 형식으로 제공하지만 이러한 방법을 지정 않는다 지도 나 변수를 플로트로 사용할 수 있습니다. 또한 RDD의 모든 회선에서이 작업을 수행해야합니다.
편집 : 배열에 인덱스를 추가하고 지금은 성공적으로 나는 RDD에서 하나 개의 항목에 그것을 할 만 할 수있는 변수에 할당 관리하지만 한 경우
val linesWithAge = lines.filter(line => line.contains("Age=")) //transformations from the original input data
val repSplit = linesWithAge.flatMap(line => line.split("\""))
val withIndex = repSplit.zipWithIndex
val indexKey = withIndex.map{case (k,v) => (v,k)}
val b = indexKey.lookup(3)
println(b)
그래서 아는 사람 않습니다 내가 어떻게 모든 항목에 그것을 할 수 있을까?
당신은'map' 함수를 찾고 있습니다.빠른 검색을 통해 다음 예제를 얻을 수 있습니다. http://backtobazics.com/big-data/spark/apache-spark-map-example/ – maasg
지도 함수가 매개 변수로 어떤 함수를 사용합니까? 데이터 세트의 각 행에 대해 3과 23의 색인을 수집하려고합니다. 이미지도 함수를 사용해 보았으므로 예제를 제공해 줄 수 있습니까? –
배열을 취해 두 개의 숫자로 된 튜플을 생성하는 함수 :'f : Array [String] => (Int, Int)'아마 시도해 볼 수 있을까요? 그렇게하는 법을 모른다면 많은 학습 자료가 있습니다. – maasg