Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Solved Go to solution

what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Explorer

Hi,

what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

I know RDD.map(e => e.split(",")) would split a string with ',' separated. But, I don't get the (1) in the code. Could somebody give me some information on this? I would greatly appreciate your answer. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Mentor

I'm not familiar with Scala but their docs are similar to Java so I would guess it would return the item at the first index of the result array.

3 REPLIES 3

Re: what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Mentor

I'm not familiar with Scala but their docs are similar to Java so I would guess it would return the item at the first index of the result array.

Re: what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Explorer

Hi Artem Ervits,

Thank you very much for your valuable time . I tried and it did exactly the same what you said. Once again Thanks!

Re: what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

Mentor

Glad to help, I learned something too about Scala, it was a mutual benefit

Don't have an account?
Coming from Hortonworks? Activate your account here